aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-13 23:11:38 +0000
committerChris Lattner <sabre@nondot.org>2007-01-13 23:11:38 +0000
commita5c5e7715c107d051f59b2f0ef78d6acd9229afa (patch)
tree605747eca2f5ba972deba2444c32762d08891d37
parentac3e76ca8ffd354a72761b731d4efc8cd8034f0b (diff)
Fix Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll, which is part
of PR1107 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33185 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index aecc9a93ef..743502240d 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -5263,9 +5263,19 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
RHSCIOp = CI->getOperand(0);
if (RHSCIOp->getType() != LHSCIOp->getType())
return 0;
- else
- // Okay, just insert a compare of the reduced operands now!
- return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
+
+ // If the signedness of the two compares doesn't agree (i.e. one is a sext
+ // and the other is a zext), then we can't handle this.
+ if (CI->getOpcode() != LHSCI->getOpcode())
+ return 0;
+
+ // Likewise, if the signedness of the [sz]exts and the compare don't match,
+ // then we can't handle this.
+ if (isSignedExt != isSignedCmp && !ICI.isEquality())
+ return 0;
+
+ // Okay, just insert a compare of the reduced operands now!
+ return new ICmpInst(ICI.getPredicate(), LHSCIOp, RHSCIOp);
}
// If we aren't dealing with a constant on the RHS, exit early