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

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 2 17:32:04 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.59 -> 1.60
---
Log message:

when checking if we should move a split edge block outside of a loop, 
check the presplit pred, not the post-split pred.  This was causing us
to make the wrong decision in some cases, leaving the critical edge block
in the loop.


---
Diffs of the changes:  (+6 -7)

 LoopStrengthReduce.cpp |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.59 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.60
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.59	Tue Sep 27 16:10:32 2005
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Sun Oct  2 19:31:52 2005
@@ -462,20 +462,19 @@
       // code on all predecessor/successor paths.  We do this unless this is the
       // canonical backedge for this loop, as this can make some inserted code
       // be in an illegal position.
-      if (e != 1 &&
-          PN->getIncomingBlock(i)->getTerminator()->getNumSuccessors() > 1 &&
-          (PN->getParent() != L->getHeader() ||
-           !L->contains(PN->getIncomingBlock(i)))) {
+      BasicBlock *PHIPred = PN->getIncomingBlock(i);
+      if (e != 1 && PHIPred->getTerminator()->getNumSuccessors() > 1 &&
+          (PN->getParent() != L->getHeader() || !L->contains(PHIPred))) {
 
+        
         // First step, split the critical edge.
-        SplitCriticalEdge(PN->getIncomingBlock(i), PN->getParent(), P);
+        SplitCriticalEdge(PHIPred, PN->getParent(), P);
             
         // Next step: move the basic block.  In particular, if the PHI node
         // is outside of the loop, and PredTI is in the loop, we want to
         // move the block to be immediately before the PHI block, not
         // immediately after PredTI.
-        if (L->contains(PN->getIncomingBlock(i)) &&
-            !L->contains(PN->getParent())) {
+        if (L->contains(PHIPred) && !L->contains(PN->getParent())) {
           BasicBlock *NewBB = PN->getIncomingBlock(i);
           NewBB->moveBefore(PN->getParent());
         }






More information about the llvm-commits mailing list