Process the step before the start, because it's usually the simpler
authorDan Gohman <gohman@apple.com>
Thu, 19 Aug 2010 01:02:31 +0000 (01:02 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 19 Aug 2010 01:02:31 +0000 (01:02 +0000)
of the two.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111495 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index f7b67113bd8562b92b0b086d5be11439eddd815c..64d493c514de86c4fe0661691fa2001a9ea83489 100644 (file)
@@ -441,12 +441,12 @@ static const SCEV *getExactSDiv(const SCEV *LHS, const SCEV *RHS,
   // Distribute the sdiv over addrec operands, if the addrec doesn't overflow.
   if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(LHS)) {
     if (IgnoreSignificantBits || isAddRecSExtable(AR, SE)) {
-      const SCEV *Start = getExactSDiv(AR->getStart(), RHS, SE,
-                                       IgnoreSignificantBits);
-      if (!Start) return 0;
       const SCEV *Step = getExactSDiv(AR->getStepRecurrence(SE), RHS, SE,
                                       IgnoreSignificantBits);
       if (!Step) return 0;
+      const SCEV *Start = getExactSDiv(AR->getStart(), RHS, SE,
+                                       IgnoreSignificantBits);
+      if (!Start) return 0;
       return SE.getAddRecExpr(Start, Step, AR->getLoop());
     }
     return 0;