summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-06-17 01:02:31 +0000
committerChris Lattner <sabre@nondot.org>2006-06-17 01:02:31 +0000
commit053fb9319d825d4593a90da8b74493152c5fa27c (patch)
tree10a32cd0cbd3e537636dfbe833dc2a7a49809d17 /llvm/lib
parentfefc14d89171877c4b1ac0b25619a2a3d6a27b74 (diff)
downloadbcm5719-llvm-053fb9319d825d4593a90da8b74493152c5fa27c.tar.gz
bcm5719-llvm-053fb9319d825d4593a90da8b74493152c5fa27c.zip
Fix IndVarsSimplify/2006-06-16-Indvar-LCSSA-Crash.ll, a case where a
"LCSSA" phi node causes indvars to break dominance properties. This fixes causes indvars to avoid inserting aggressive code in this case, instead indvars should be fixed to be more aggressive in the face of lcssa phi's. llvm-svn: 28850
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/IndVarSimplify.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
index 72ddb07d1eb..a46916077ae 100644
--- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -321,11 +321,26 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
HasConstantItCount) {
// Find out if this predictably varying value is actually used
// outside of the loop. "extra" as opposed to "intra".
- std::vector<User*> ExtraLoopUsers;
+ std::vector<Instruction*> ExtraLoopUsers;
for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
- UI != E; ++UI)
- if (!L->contains(cast<Instruction>(*UI)->getParent()))
- ExtraLoopUsers.push_back(*UI);
+ UI != E; ++UI) {
+ Instruction *User = cast<Instruction>(*UI);
+ if (!L->contains(User->getParent())) {
+ // If this is a PHI node in the exit block and we're inserting,
+ // into the exit block, it must have a single entry. In this
+ // case, we can't insert the code after the PHI and have the PHI
+ // still use it. Instead, don't insert the the PHI.
+ if (PHINode *PN = dyn_cast<PHINode>(User)) {
+ // FIXME: This is a case where LCSSA pessimizes code, this
+ // should be fixed better.
+ if (PN->getNumOperands() == 2 &&
+ PN->getParent() == BlockToInsertInto)
+ continue;
+ }
+ ExtraLoopUsers.push_back(User);
+ }
+ }
+
if (!ExtraLoopUsers.empty()) {
// Okay, this instruction has a user outside of the current loop
// and varies predictably in this loop. Evaluate the value it
OpenPOWER on IntegriCloud