[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Jun 13 21:46:29 PDT 2006
Changes in directory llvm/lib/Transforms/Scalar:
LoopUnswitch.cpp updated: 1.39 -> 1.40
---
Log message:
Fix Transforms/LoopUnswitch/2006-06-13-SingleEntryPHI.ll, a loop unswitch
bug exposed by the recent lcssa work.
---
Diffs of the changes: (+13 -1)
LoopUnswitch.cpp | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletion(-)
Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.39 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.40
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.39 Mon Jun 12 16:49:21 2006
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Jun 13 23:46:17 2006
@@ -401,7 +401,7 @@
<< Cost << "\n");
return false;
}
-
+
// If this is a trivial condition to unswitch (which results in no code
// duplication), do it now.
Constant *CondVal;
@@ -456,6 +456,18 @@
// If the successor only has a single pred, split the top of the successor
// block.
assert(SP == BB && "CFG broken");
+
+ // If this block has a single predecessor, remove any phi nodes. Unswitch
+ // expect that, after split the edges from inside the loop to the exit
+ // block, that there will be no phi nodes in the new exit block. Single
+ // entry phi nodes break this assumption.
+ BasicBlock::iterator I = Succ->begin();
+ while (PHINode *PN = dyn_cast<PHINode>(I)) {
+ PN->replaceAllUsesWith(PN->getIncomingValue(0));
+ PN->eraseFromParent();
+ I = Succ->begin();
+ }
+
return SplitBlock(Succ, Succ->begin());
} else {
// Otherwise, if BB has a single successor, split it at the bottom of the
More information about the llvm-commits
mailing list