diff options
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/icmp.ll | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index f51cf7321f2..6a38baefe5a 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -3150,7 +3150,7 @@ static ICmpInst *canonicalizeCmpWithConstant(ICmpInst &I) { // Increment or decrement the constant and set the new comparison predicate: // ULE -> ULT ; UGE -> UGT ; SLE -> SLT ; SGE -> SGT - Constant *OneOrNegOne = ConstantInt::get(Op1Type, IsLE ? 1 : -1, IsSigned); + Constant *OneOrNegOne = ConstantInt::get(Op1Type, IsLE ? 1 : -1, true); CmpInst::Predicate NewPred = IsLE ? ICmpInst::ICMP_ULT: ICmpInst::ICMP_UGT; NewPred = IsSigned ? ICmpInst::getSignedPredicate(NewPred) : NewPred; return new ICmpInst(NewPred, Op0, ConstantExpr::getAdd(Op1C, OneOrNegOne)); diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll index 099d15944ab..4575e1017ff 100644 --- a/llvm/test/Transforms/InstCombine/icmp.ll +++ b/llvm/test/Transforms/InstCombine/icmp.ll @@ -2098,7 +2098,7 @@ return: ; preds = %if.end, %entry, %if ret void } -; When canonicalizing to 'sgt', make sure the constant is correct. +; When canonicalizing to 'gt/lt', make sure the constant is correct. define i1 @PR27792(i128 %a) { ; CHECK-LABEL: @PR27792( @@ -2109,3 +2109,12 @@ define i1 @PR27792(i128 %a) { ret i1 %cmp } +define i1 @PR27792_2(i128 %a) { +; CHECK-LABEL: @PR27792_2( +; CHECK-NEXT: [[B:%.*]] = icmp ne i128 %a, 0 +; CHECK-NEXT: ret i1 [[B]] +; + %b = icmp uge i128 %a, 1 + ret i1 %b +} + |

