[llvm] r269831 - [InstCombine] add another test for wrong icmp constant (PR27792)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue May 17 13:20:40 PDT 2016
Author: spatel
Date: Tue May 17 15:20:40 2016
New Revision: 269831
URL: http://llvm.org/viewvc/llvm-project?rev=269831&view=rev
Log:
[InstCombine] add another test for wrong icmp constant (PR27792)
It doesn't matter if the comparison is unsigned; the inc/dec is always signed.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/trunk/test/Transforms/InstCombine/icmp.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=269831&r1=269830&r2=269831&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue May 17 15:20:40 2016
@@ -3150,7 +3150,7 @@ static ICmpInst *canonicalizeCmpWithCons
// 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));
Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=269831&r1=269830&r2=269831&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Tue May 17 15:20:40 2016
@@ -2098,7 +2098,7 @@ return:
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
+}
+
More information about the llvm-commits
mailing list