diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-17 18:08:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-17 18:08:33 +0000 |
commit | f50af088f19f525f3d1026eb61db77e0037a9f43 (patch) | |
tree | b0a068d29dfedd7305b4a8962fef63468bafef0d /lib/Transforms/Scalar/IndVarSimplify.cpp | |
parent | f5b9eb37a92a36e80bacc21a89f538731ed63aa2 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13015 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 9bc897fe02..fa81f81f74 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/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. // |