diff options
| author | Devang Patel <dpatel@apple.com> | 2007-08-24 05:36:56 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2007-08-24 05:36:56 +0000 |
| commit | 5e46fac6debf7af41ac8233479dfef822146efa8 (patch) | |
| tree | ca3d0a690d7080d815ea19a1383d557ec9cf91af /llvm | |
| parent | 2da04b332264ae6cf72f7c87beee8a0f9d0a7eb0 (diff) | |
| download | bcm5719-llvm-5e46fac6debf7af41ac8233479dfef822146efa8.tar.gz bcm5719-llvm-5e46fac6debf7af41ac8233479dfef822146efa8.zip | |
Tightenup loop filter.
llvm-svn: 41356
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp index 854b172422b..6b69ecefef0 100644 --- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -272,7 +272,12 @@ void LoopIndexSplit::findLoopConditionals() { if (!ExitingBlock) return; - + + // If exiting block is neither loop header nor loop latch then this loop is + // not suitable. + if (ExitingBlock != L->getHeader() && ExitingBlock != L->getLoopLatch()) + return; + // If exit block's terminator is conditional branch inst then we have found // exit condition. BranchInst *BR = dyn_cast<BranchInst>(ExitingBlock->getTerminator()); @@ -705,7 +710,22 @@ bool LoopIndexSplit::safeSplitCondition(SplitInfo &SD) { if (Succ0 == *PI) return false; - return true; + // Finally this split condition is safe only if merge point for + // split condition branch is loop latch. This check along with previous + // check, to ensure that exit condition is in either loop latch or header, + // filters all loops with non-empty loop body between merge point + // and exit condition. + DominanceFrontier::iterator Succ0DF = DF->find(Succ0); + assert (Succ0DF != DF->end() && "Unable to find Succ0 dominance frontier"); + if (Succ0DF->second.count(Latch)) + return true; + + DominanceFrontier::iterator Succ1DF = DF->find(Succ1); + assert (Succ1DF != DF->end() && "Unable to find Succ1 dominance frontier"); + if (Succ1DF->second.count(Latch)) + return true; + + return false; } /// splitLoop - Split current loop L in two loops using split information |

