llvm.org GIT mirror llvm / 3ee29bf
Merge 80761 from mainline. fix PR4837, some bugs folding vector compares. These return a vector of i1, not i1 itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@81027 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 10 years ago
2 changed file(s) with 13 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
58875887
58885888 // Fold trivial predicates.
58895889 if (I.getPredicate() == FCmpInst::FCMP_FALSE)
5890 return ReplaceInstUsesWith(I, ConstantInt::getFalse(*Context));
5890 return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 0));
58915891 if (I.getPredicate() == FCmpInst::FCMP_TRUE)
5892 return ReplaceInstUsesWith(I, ConstantInt::getTrue(*Context));
5892 return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 1));
58935893
58945894 // Simplify 'fcmp pred X, X'
58955895 if (Op0 == Op1) {
58985898 case FCmpInst::FCMP_UEQ: // True if unordered or equal
58995899 case FCmpInst::FCMP_UGE: // True if unordered, greater than, or equal
59005900 case FCmpInst::FCMP_ULE: // True if unordered, less than, or equal
5901 return ReplaceInstUsesWith(I, ConstantInt::getTrue(*Context));
5901 return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 1));
59025902 case FCmpInst::FCMP_OGT: // True if ordered and greater than
59035903 case FCmpInst::FCMP_OLT: // True if ordered and less than
59045904 case FCmpInst::FCMP_ONE: // True if ordered and operands are unequal
5905 return ReplaceInstUsesWith(I, ConstantInt::getFalse(*Context));
5905 return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 0));
59065906
59075907 case FCmpInst::FCMP_UNO: // True if unordered: isnan(X) | isnan(Y)
59085908 case FCmpInst::FCMP_ULT: // True if unordered or less than
59255925 }
59265926
59275927 if (isa(Op1)) // fcmp pred X, undef -> undef
5928 return ReplaceInstUsesWith(I, UndefValue::get(Type::getInt1Ty(*Context)));
5928 return ReplaceInstUsesWith(I, UndefValue::get(I.getType()));
59295929
59305930 // Handle fcmp with constant RHS
59315931 if (Constant *RHSC = dyn_cast(Op1)) {
59955995
59965996 // icmp X, X
59975997 if (Op0 == Op1)
5998 return ReplaceInstUsesWith(I, ConstantInt::get(Type::getInt1Ty(*Context),
5998 return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(),
59995999 I.isTrueWhenEqual()));
60006000
60016001 if (isa(Op1)) // X icmp undef -> undef
6002 return ReplaceInstUsesWith(I, UndefValue::get(Type::getInt1Ty(*Context)));
6002 return ReplaceInstUsesWith(I, UndefValue::get(I.getType()));
60036003
60046004 // icmp , - Global/Stack value
60056005 // addresses never equal each other! We already know that Op0 != Op1.
2727 ret i32 %1
2828 }
2929
30 ; PR4837
31 define <2 x i1> @test5(<2 x i64> %x) {
32 entry:
33 %V = icmp eq <2 x i64> %x, undef
34 ret <2 x i1> %V
35 }