diff options
| author | Devang Patel <dpatel@apple.com> | 2007-08-20 20:24:15 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2007-08-20 20:24:15 +0000 |
| commit | c2e2d15f458579dd8cc9f3040224e9886961c467 (patch) | |
| tree | a0ad51195a2d592ef44708afc7d00426538a59f7 /llvm/lib | |
| parent | 8766c1684080d3b64e19ea5cf639cbf3cf8d632d (diff) | |
| download | bcm5719-llvm-c2e2d15f458579dd8cc9f3040224e9886961c467.tar.gz bcm5719-llvm-c2e2d15f458579dd8cc9f3040224e9886961c467.zip | |
Do not split loops rejected by processOneIterationLoop().
llvm-svn: 41194
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp index 9b4319d40cd..4a5c1c8cc0b 100644 --- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -178,7 +178,7 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { // First see if it is possible to eliminate loop itself or not. for (SmallVector<SplitInfo, 4>::iterator SI = SplitData.begin(), - E = SplitData.end(); SI != E; ++SI) { + E = SplitData.end(); SI != E;) { SplitInfo &SD = *SI; if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) { Changed = processOneIterationLoop(SD); @@ -186,8 +186,13 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { ++NumIndexSplit; // If is loop is eliminated then nothing else to do here. return Changed; + } else { + SmallVector<SplitInfo, 4>::iterator Delete_SI = SI; + ++SI; + SplitData.erase(Delete_SI); } - } + } else + ++SI; } unsigned MaxCost = 99; @@ -198,8 +203,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { SplitInfo SD = *SI; // ICM_EQs are already handled above. - if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) - continue; + assert (SD.SplitCondition->getPredicate() != ICmpInst::ICMP_EQ && + "Unexpected split condition predicate"); unsigned Cost = findSplitCost(L, SD); if (Cost < MaxCost) @@ -207,7 +212,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) { } // Split most profitiable condition. - Changed = splitLoop(SplitData[MostProfitableSDIndex]); + if (!SplitData.empty()) + Changed = splitLoop(SplitData[MostProfitableSDIndex]); if (Changed) ++NumIndexSplit; |

