summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-17 18:08:33 +0000
committerChris Lattner <sabre@nondot.org>2004-04-17 18:08:33 +0000
commit885a6eb74d95ce72090bff2e59a0231be2ea2283 (patch)
tree87be1de5f20f611daf416d3ed266218ece0d9537 /llvm/lib/Transforms
parenta43312d30b545b1bc2720af343f90a95a11629e7 (diff)
downloadbcm5719-llvm-885a6eb74d95ce72090bff2e59a0231be2ea2283.tar.gz
bcm5719-llvm-885a6eb74d95ce72090bff2e59a0231be2ea2283.zip
Even if there are not any induction variables in the loop, if we can compute
the trip count for the loop, insert one so that we can canonicalize the exit condition. llvm-svn: 13015
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 9bc897fe022..fa81f81f743 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -368,7 +368,17 @@ void IndVarSimplify::runOnLoop(Loop *L) {
// If there are no induction variables in the loop, there is nothing more to
// do.
- if (IndVars.empty()) return;
+ if (IndVars.empty()) {
+ // Actually, if we know how many times the loop iterates, lets insert a
+ // canonical induction variable to help subsequent passes.
+ if (!isa<SCEVCouldNotCompute>(IterationCount)) {
+ ScalarEvolutionRewriter Rewriter(*SE, *LI);
+ Rewriter.GetOrInsertCanonicalInductionVariable(L,
+ IterationCount->getType());
+ LinearFunctionTestReplace(L, IterationCount, Rewriter);
+ }
+ return;
+ }
// Compute the type of the largest recurrence expression.
//
OpenPOWER on IntegriCloud