diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-01-13 23:11:38 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-01-13 23:11:38 +0000 |
| commit | 387bf3f700d1ebaf0e276a6c60ddd7e6e29c5cc2 (patch) | |
| tree | 28de5294c536135231311ce01787bf04cc2156c4 /llvm/lib/Transforms | |
| parent | 47bb5c996ef4c0c65def1302594c0961f89553e6 (diff) | |
| download | bcm5719-llvm-387bf3f700d1ebaf0e276a6c60ddd7e6e29c5cc2.tar.gz bcm5719-llvm-387bf3f700d1ebaf0e276a6c60ddd7e6e29c5cc2.zip | |
Fix Transforms/InstCombine/2007-01-13-ExtCompareMiscompile.ll, which is part
of PR1107
llvm-svn: 33185
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index aecc9a93ef1..743502240d4 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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 |

