diff options
author | Devang Patel <dpatel@apple.com> | 2007-08-18 00:00:32 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-08-18 00:00:32 +0000 |
commit | 20d260a193c1d605c8b6c19ab65717787ea24ff9 (patch) | |
tree | 342cdd1b9ac3b8696215fd26867363e84fd38d06 /lib/Transforms/Scalar/LoopIndexSplit.cpp | |
parent | 7bfd5dba387088b371f0d904364e976a71afbd4f (diff) |
Avoid spliting loops where two split condition branches are not independent.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIndexSplit.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopIndexSplit.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index 980990ea65..9b4319d40c 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/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(); |