[llvm-commits] [llvm] r101032 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Dan Gohman gohman at apple.com
Mon Apr 12 00:56:56 PDT 2010


Author: djg
Date: Mon Apr 12 02:56:56 2010
New Revision: 101032

URL: http://llvm.org/viewvc/llvm-project?rev=101032&view=rev
Log:
Move the EliminateIVUsers call back out to its original location. Now that
a ScalarEvolution bug with overflow handling is fixed, the normal analysis
code will automatically decline to operate on the icmp instructions which
are responsible for the loop exit.

Modified:
    llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=101032&r1=101031&r2=101032&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon Apr 12 02:56:56 2010
@@ -406,6 +406,9 @@
   if (!isa<SCEVCouldNotCompute>(BackedgeTakenCount))
     RewriteLoopExitValues(L, Rewriter);
 
+  // Simplify ICmp IV users.
+  EliminateIVComparisons();
+
   // Compute the type of the largest recurrence expression, and decide whether
   // a canonical induction variable should be inserted.
   const Type *LargestType = 0;
@@ -471,19 +474,10 @@
       ExitingBlock) {
     assert(NeedCannIV &&
            "LinearFunctionTestReplace requires a canonical induction variable");
-
     // Can't rewrite non-branch yet.
-    if (BranchInst *BI = dyn_cast<BranchInst>(ExitingBlock->getTerminator())) {
-      // Eliminate comparisons which are always true or always false, due to
-      // the known backedge-taken count. This may include comparisons which
-      // are currently controlling (part of) the loop exit, so we can only do
-      // it when we know we're going to insert our own loop exit code.
-      EliminateIVComparisons();
-
-      // Insert new loop exit code.
+    if (BranchInst *BI = dyn_cast<BranchInst>(ExitingBlock->getTerminator()))
       NewICmp = LinearFunctionTestReplace(L, BackedgeTakenCount, IndVar,
                                           ExitingBlock, BI, Rewriter);
-    }
   }
 
   // Rewrite IV-derived expressions. Clears the rewriter cache.





More information about the llvm-commits mailing list