Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.762 -> 1.763
---
Log message:

fix Transforms/InstCombine/2007-05-10-icmp-or.ll


---
Diffs of the changes:  (+10 -5)

 InstructionCombining.cpp |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.762 
llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.763
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.762   Sun May  6 
08:37:16 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Fri May 11 00:55:56 2007
@@ -3919,13 +3919,18 @@
             LHSCC != ICmpInst::ICMP_UGE && LHSCC != ICmpInst::ICMP_ULE &&
             RHSCC != ICmpInst::ICMP_UGE && RHSCC != ICmpInst::ICMP_ULE &&
             LHSCC != ICmpInst::ICMP_SGE && LHSCC != ICmpInst::ICMP_SLE &&
-            RHSCC != ICmpInst::ICMP_SGE && RHSCC != ICmpInst::ICMP_SLE) {
+            RHSCC != ICmpInst::ICMP_SGE && RHSCC != ICmpInst::ICMP_SLE &&
+            // We can't fold (ugt x, C) | (sgt x, C2).
+            PredicatesFoldable(LHSCC, RHSCC)) {
           // Ensure that the larger constant is on the RHS.
-          ICmpInst::Predicate GT = ICmpInst::isSignedPredicate(LHSCC) ? 
-            ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
-          Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst);
           ICmpInst *LHS = cast<ICmpInst>(Op0);
-          if (cast<ConstantInt>(Cmp)->getZExtValue()) {
+          bool NeedsSwap;
+          if (ICmpInst::isSignedPredicate(LHSCC))
+            NeedsSwap = LHSCst->getValue().sgt(LHSCst->getValue());
+          else
+            NeedsSwap = LHSCst->getValue().ugt(LHSCst->getValue());
+            
+          if (NeedsSwap) {
             std::swap(LHS, RHS);
             std::swap(LHSCst, RHSCst);
             std::swap(LHSCC, RHSCC);



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to