forked from OSchip/llvm-project
[InstCombine] Don't transform (X+INT_MAX)>=(Y+INT_MAX) -> (X<=Y)
This miscompile came about because we tried to use a transform which was only appropriate for xor operators when addition was present. This fixes PR26407. llvm-svn: 259375
This commit is contained in:
parent
ca832660ae
commit
f8853ae7b3
|
@ -3877,7 +3877,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
|||
BO1->getOperand(0));
|
||||
}
|
||||
|
||||
if (CI->isMaxValue(true)) {
|
||||
if (BO0->getOpcode() == Instruction::Xor && CI->isMaxValue(true)) {
|
||||
ICmpInst::Predicate Pred = I.isSigned()
|
||||
? I.getUnsignedPredicate()
|
||||
: I.getSignedPredicate();
|
||||
|
|
|
@ -1672,3 +1672,15 @@ define i1 @cmp_slt_rhs_inc(float %x, i32 %i) {
|
|||
%cmp = icmp slt i32 %conv, %inc
|
||||
ret i1 %cmp
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @PR26407
|
||||
; CHECK-NEXT: %[[addx:.*]] = add i32 %x, 2147483647
|
||||
; CHECK-NEXT: %[[addy:.*]] = add i32 %y, 2147483647
|
||||
; CHECK-NEXT: %[[cmp:.*]] = icmp uge i32 %[[addx]], %[[addy]]
|
||||
; CHECK-NEXT: ret i1 %[[cmp]]
|
||||
define i1 @PR26407(i32 %x, i32 %y) {
|
||||
%addx = add i32 %x, 2147483647
|
||||
%addy = add i32 %y, 2147483647
|
||||
%cmp = icmp uge i32 %addx, %addy
|
||||
ret i1 %cmp
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue