[llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Apr 17 18:36:08 PDT 2004


Changes in directory llvm/lib/Transforms/Scalar:

IndVarSimplify.cpp updated: 1.56 -> 1.57

---
Log message:

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.


---
Diffs of the changes:  (+11 -1)

Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.56 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.57
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.56	Fri Apr 16 01:03:17 2004
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp	Sat Apr 17 13:08:33 2004
@@ -368,7 +368,17 @@
 
   // 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.
   //





More information about the llvm-commits mailing list