summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-26 18:35:46 +0000
committerChris Lattner <sabre@nondot.org>2009-11-26 18:35:46 +0000
commitd7cabea8caf56fcce634bb9d35fde3ba61647523 (patch)
tree660f2ab6e1cd1c0e7f1c84de47b75ff960c40495 /llvm
parent9aa846956efbc2d6621265d81209488c7414995c (diff)
downloadbcm5719-llvm-d7cabea8caf56fcce634bb9d35fde3ba61647523.tar.gz
bcm5719-llvm-d7cabea8caf56fcce634bb9d35fde3ba61647523.zip
fix two transposed lines duncan caught and add an explanatory comment.
llvm-svn: 89958
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 37d5ad32870..5439bbff269 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud