diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-26 18:35:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-26 18:35:46 +0000 |
commit | b18004c13c0c494305b0ce1d748049f8c580bd99 (patch) | |
tree | 9b3f87cc2c189aee0b1e214116cd72c32cc1f479 | |
parent | 8fe8ac725b05ffabc9ab49ef7fa3f99746f4ee54 (diff) | |
download | external_llvm-b18004c13c0c494305b0ce1d748049f8c580bd99.zip external_llvm-b18004c13c0c494305b0ce1d748049f8c580bd99.tar.gz external_llvm-b18004c13c0c494305b0ce1d748049f8c580bd99.tar.bz2 |
fix two transposed lines duncan caught and add an explanatory comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89958 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/ValueTracking.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 37d5ad3..5439bbf 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -1064,12 +1064,15 @@ const Value *llvm::DecomposeGEPExpression(const Value *V, int64_t &BaseOffs, 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 |