summaryrefslogtreecommitdiff
path: root/lib/Analysis/ScalarEvolutionExpander.cpp
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-06 08:20:29 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-06 08:20:29 +0000
commitf4fe016fa15f703fe9c1b932d1e81e2c718521db (patch)
tree8a1bbd1a5b838080d31e5c93a1817006b8c62318 /lib/Analysis/ScalarEvolutionExpander.cpp
parent68eb509bdc5c7007520d5231cd92de28106236df (diff)
Notes
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r--lib/Analysis/ScalarEvolutionExpander.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp
index 7ba8268b508a..ef77e46fc99a 100644
--- a/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -644,3 +644,16 @@ Value *SCEVExpander::expand(const SCEV *S) {
InsertedExpressions[S] = V;
return V;
}
+
+/// getOrInsertCanonicalInductionVariable - This method returns the
+/// canonical induction variable of the specified type for the specified
+/// loop (inserting one if there is none). A canonical induction variable
+/// starts at zero and steps by one on each iteration.
+Value *
+SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L,
+ const Type *Ty) {
+ assert(Ty->isInteger() && "Can only insert integer induction variables!");
+ SCEVHandle H = SE.getAddRecExpr(SE.getIntegerSCEV(0, Ty),
+ SE.getIntegerSCEV(1, Ty), L);
+ return expand(H);
+}