summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-08-18 00:00:32 +0000
committerDevang Patel <dpatel@apple.com>2007-08-18 00:00:32 +0000
commit1282b6e18127808bc4013613508bf6443e5937d8 (patch)
tree832d716efc7b9f1e1928d705c26e058810ad9528 /llvm/lib/Transforms
parentcb173fc7d005af4af2b74f554f02d276931dd434 (diff)
downloadbcm5719-llvm-1282b6e18127808bc4013613508bf6443e5937d8.tar.gz
bcm5719-llvm-1282b6e18127808bc4013613508bf6443e5937d8.zip
Avoid spliting loops where two split condition branches are not independent.
llvm-svn: 41148
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 980990ea652..9b4319d40cd 100644
--- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -711,12 +711,22 @@ bool LoopIndexSplit::splitLoop(SplitInfo &SD) {
|| Latch == SplitTerminator->getSuccessor(1)))
return false;
-
+ // If one of the split condition branch is post dominating other then loop
+ // index split is not appropriate.
BasicBlock *Succ0 = SplitTerminator->getSuccessor(0);
BasicBlock *Succ1 = SplitTerminator->getSuccessor(1);
if (DT->dominates(Succ0, Latch) || DT->dominates(Succ1, Latch))
return false;
+ // If one of the split condition branch is a predecessor of the other
+ // split condition branch head then do not split loop on this condition.
+ for(pred_iterator PI = pred_begin(Succ0), PE = pred_end(Succ0); PI != PE; ++PI)
+ if (Succ1 == *PI)
+ return false;
+ for(pred_iterator PI = pred_begin(Succ1), PE = pred_end(Succ1); PI != PE; ++PI)
+ if (Succ0 == *PI)
+ return false;
+
// True loop is original loop. False loop is cloned loop.
bool SignedPredicate = ExitCondition->isSignedPredicate();
OpenPOWER on IntegriCloud