do some computation with apints instead of ConstantInts.
authorChris Lattner <sabre@nondot.org>
Sun, 16 Nov 2008 05:14:43 +0000 (05:14 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 16 Nov 2008 05:14:43 +0000 (05:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59401 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index a8dcfa447da0430b26ee1f077a2447fca0ba97e1..acea4bd49a5a0ba1ee7577feb3a6cd7f13cf236c 100644 (file)
@@ -3590,16 +3590,15 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I,
     return 0;
     
   // Ensure that the larger constant is on the RHS.
-  ICmpInst::Predicate GT;
+  bool ShouldSwap;
   if (ICmpInst::isSignedPredicate(LHSCC) ||
       (ICmpInst::isEquality(LHSCC) && 
        ICmpInst::isSignedPredicate(RHSCC)))
-    GT = ICmpInst::ICMP_SGT;
+    ShouldSwap = LHSCst->getValue().sgt(RHSCst->getValue());
   else
-    GT = ICmpInst::ICMP_UGT;
-  
-  Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst);
-  if (cast<ConstantInt>(Cmp)->getZExtValue()) {
+    ShouldSwap = LHSCst->getValue().ugt(RHSCst->getValue());
+    
+  if (ShouldSwap) {
     std::swap(LHS, RHS);
     std::swap(LHSCst, RHSCst);
     std::swap(LHSCC, RHSCC);