[llvm-commits] [llvm] r60442 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Dale Johannesen dalej at apple.com
Tue Dec 2 13:17:13 PST 2008


Author: johannes
Date: Tue Dec  2 15:17:11 2008
New Revision: 60442

URL: http://llvm.org/viewvc/llvm-project?rev=60442&view=rev
Log:
Minor rewrite per review feedback.


Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=60442&r1=60441&r2=60442&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Tue Dec  2 15:17:11 2008
@@ -996,9 +996,14 @@
   
   // Otherwise, remove all of the CSE's we found from each of the base values.
   for (unsigned i = 0; i != NumUses; ++i) {
-    // For this purpose, consider only uses that are inside the loop.
-    if (!L->contains(Uses[i].Inst->getParent()))
+    // Uses outside the loop don't necessarily include the common base, but
+    // the final IV value coming into those uses does.  Instead of trying to
+    // remove the pieces of the common base, which might not be there,
+    // subtract off the base to compensate for this.
+    if (!L->contains(Uses[i].Inst->getParent())) {
+      Uses[i].Base = SE->getMinusSCEV(Uses[i].Base, Result);
       continue;
+    }
 
     // Split the expression into subexprs.
     SeparateSubExprs(SubExprs, Uses[i].Base, SE);
@@ -1476,12 +1481,6 @@
         // Add BaseV to the PHI value if needed.
         RewriteExpr = SE->getAddExpr(RewriteExpr, SE->getUnknown(BaseV));
 
-      // If this reference is not in the loop and we have a Common base,
-      // that has been added into the induction variable and must be
-      // subtracted off here.
-      if (HaveCommonExprs && !L->contains(User.Inst->getParent()))
-        RewriteExpr = SE->getMinusSCEV(RewriteExpr, CommonExprs);
-
       User.RewriteInstructionToUseNewBase(RewriteExpr, NewBasePt,
                                           Rewriter, L, this,
                                           DeadInsts);





More information about the llvm-commits mailing list