[llvm-commits] [llvm] r89958 - /llvm/trunk/lib/Analysis/ValueTracking.cpp

Chris Lattner sabre at nondot.org
Thu Nov 26 10:35:46 PST 2009


Author: lattner
Date: Thu Nov 26 12:35:46 2009
New Revision: 89958

URL: http://llvm.org/viewvc/llvm-project?rev=89958&view=rev
Log:
fix two transposed lines duncan caught and add an explanatory comment.

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

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=89958&r1=89957&r2=89958&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Thu Nov 26 12:35:46 2009
@@ -1064,12 +1064,15 @@
       
       uint64_t Scale = TD->getTypeAllocSize(*GTI);
       
+      // Use GetLinearExpression to decompose the index into a C1*V+C2 form.
       unsigned Width = cast<IntegerType>(Index->getType())->getBitWidth();
       APInt IndexScale(Width, 0), IndexOffset(Width, 0);
       Index = GetLinearExpression(Index, IndexScale, IndexOffset, TD);
       
-      Scale *= IndexScale.getZExtValue();
+      // The GEP index scale ("Scale") scales C1*V+C2, yielding (C1*V+C2)*Scale.
+      // This gives us an aggregate computation of (C1*Scale)*V + C2*Scale.
       BaseOffs += IndexOffset.getZExtValue()*Scale;
+      Scale *= IndexScale.getZExtValue();
       
       
       // If we already had an occurrance of this index variable, merge this





More information about the llvm-commits mailing list