[llvm-commits] [llvm] r139135 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Nick Lewycky nicholas at mxc.ca
Mon Sep 5 22:33:18 PDT 2011


Author: nicholas
Date: Tue Sep  6 00:33:18 2011
New Revision: 139135

URL: http://llvm.org/viewvc/llvm-project?rev=139135&view=rev
Log:
Fix flipped sign. While there, show my math.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=139135&r1=139134&r2=139135&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Sep  6 00:33:18 2011
@@ -1976,7 +1976,13 @@
          OtherIdx < Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);
          ++OtherIdx)
       if (AddRecLoop == cast<SCEVAddRecExpr>(Ops[OtherIdx])->getLoop()) {
-        // {A,+,B}<L> * {C,+,D}<L>  -->  {A*C,+,A*D + B*C + B*D,+,2*B*D}<L>
+        // {A,+,B}<L> * {C,+,D}<L>  -->  {A*C,+,A*D + B*C - B*D,+,2*B*D}<L>
+        //
+        // For reference, given that {X,+,Y,+,Z} = x + y*It + z*It^2 then
+        // X = x, Y = y-z, Z = 2z.
+        //
+        // x = A*C, y = (A*D + B*C), z = B*D
+        // Therefore X = A*C, Y = (A*D + B*C) - B*D and Z = 2*B*D.
         for (; OtherIdx != Ops.size() && isa<SCEVAddRecExpr>(Ops[OtherIdx]);
              ++OtherIdx)
           if (const SCEVAddRecExpr *OtherAddRec =
@@ -1989,7 +1995,8 @@
               const SCEV *NewStart = getMulExpr(A, C);
               const SCEV *BD = getMulExpr(B, D);
               const SCEV *NewStep = getAddExpr(getMulExpr(A, D),
-                                               getMulExpr(B, C), BD);
+                                               getMulExpr(B, C),
+                                               getNegativeSCEV(BD));
               const SCEV *NewSecondOrderStep =
                   getMulExpr(BD, getConstant(BD->getType(), 2));
 





More information about the llvm-commits mailing list