llvm.org GIT mirror llvm / c8e14b3
fix incorrect folding of icmp with undef, PR6481. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97659 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
3 changed file(s) with 15 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
193193 const Type *ITy = GetCompareTy(LHS);
194194
195195 // icmp X, X -> true/false
196 if (LHS == RHS)
196 // X icmp undef -> true/false. For example, icmp ugt %X, undef -> false
197 // because X could be 0.
198 if (LHS == RHS || isa(RHS))
197199 return ConstantInt::get(ITy, CmpInst::isTrueWhenEqual(Pred));
198
199 if (isa(RHS)) // X icmp undef -> undef
200 return UndefValue::get(ITy);
201200
202201 // icmp , - Global/Stack value
203202 // addresses never equal each other! We already know that Op0 != Op1.
18171817
18181818 // Handle some degenerate cases first
18191819 if (isa(C1) || isa(C2))
1820 return UndefValue::get(ResultTy);
1820 return ConstantInt::get(ResultTy, CmpInst::isTrueWhenEqual(pred));
18211821
18221822 // No compile-time operations on this type yet.
18231823 if (C1->getType()->isPPC_FP128Ty())
4747 %V = icmp eq <2 x i64> %x, undef
4848 ret <2 x i1> %V
4949 ; CHECK: @test5
50 ; CHECK: ret <2 x i1> undef
50 ; CHECK: ret <2 x i1>
5151 }
5252
5353 define i32 @test6(i32 %a, i32 %b) {
120120 ; CHECK-NEXT: %B = select i1
121121 ; CHECK-NEXT: ret i1 %B
122122 }
123
124 ; PR6481
125 define i1 @test13(i8 %X) nounwind readnone {
126 entry:
127 %cmp = icmp slt i8 undef, %X
128 ret i1 %cmp
129 ; CHECK: @test13
130 ; CHECK: ret i1 false
131 }
132