summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-01-13 20:59:02 +0000
committerChris Lattner <sabre@nondot.org>2008-01-13 20:59:02 +0000
commit5bc253c8f2a8338f71b09462109859d7aae99029 (patch)
tree5af76de91711665e2deb6f43cc6c2b4e9a952c94 /llvm/lib/Transforms
parent93ebe1df270306de9e2a00d5a608f7a8a22ef4c1 (diff)
downloadbcm5719-llvm-5bc253c8f2a8338f71b09462109859d7aae99029.tar.gz
bcm5719-llvm-5bc253c8f2a8338f71b09462109859d7aae99029.zip
Fix PR1907, a nasty miscompilation because instcombine didn't
realize that ne & sgt was a signed comparison (it was only looking at whether the left compare was signed). llvm-svn: 45937
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index ea53aec76cb..9465a31d29d 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3495,8 +3495,14 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
ICmpInst::isSignedPredicate(LHSCC) ==
ICmpInst::isSignedPredicate(RHSCC))) {
// Ensure that the larger constant is on the RHS.
- ICmpInst::Predicate GT = ICmpInst::isSignedPredicate(LHSCC) ?
- ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
+ ICmpInst::Predicate GT;
+ if (ICmpInst::isSignedPredicate(LHSCC) ||
+ (ICmpInst::isEquality(LHSCC) &&
+ ICmpInst::isSignedPredicate(RHSCC)))
+ GT = ICmpInst::ICMP_SGT;
+ else
+ GT = ICmpInst::ICMP_UGT;
+
Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst);
ICmpInst *LHS = cast<ICmpInst>(Op0);
if (cast<ConstantInt>(Cmp)->getZExtValue()) {
OpenPOWER on IntegriCloud