]> granicus.if.org Git - llvm/commitdiff
[SimplifyIndVars] Shorten code by using SCEV helper [NFC]
authorPhilip Reames <listmail@philipreames.com>
Thu, 26 Oct 2017 22:02:16 +0000 (22:02 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 26 Oct 2017 22:02:16 +0000 (22:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316709 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyIndVar.cpp

index 08b84927c674d509ec81c2fa027b484294e9e0ab..5263e8ccc6d26791cedf5989558a3c23a390fa5a 100644 (file)
@@ -174,14 +174,11 @@ void SimplifyIndvar::eliminateIVComparison(ICmpInst *ICmp, Value *IVOperand) {
     Pred = ICmpInst::getSwappedPredicate(Pred);
   }
 
-  // Get the SCEVs for the ICmp operands.
-  const SCEV *S = SE->getSCEV(ICmp->getOperand(IVOperIdx));
-  const SCEV *X = SE->getSCEV(ICmp->getOperand(1 - IVOperIdx));
-
-  // Simplify unnecessary loops away.
+  // Get the SCEVs for the ICmp operands (in the specific context of the
+  // current loop)
   const Loop *ICmpLoop = LI->getLoopFor(ICmp->getParent());
-  S = SE->getSCEVAtScope(S, ICmpLoop);
-  X = SE->getSCEVAtScope(X, ICmpLoop);
+  const SCEV *S = SE->getSCEVAtScope(ICmp->getOperand(IVOperIdx), ICmpLoop);
+  const SCEV *X = SE->getSCEVAtScope(ICmp->getOperand(1 - IVOperIdx), ICmpLoop);
 
   ICmpInst::Predicate InvariantPredicate;
   const SCEV *InvariantLHS, *InvariantRHS;