Do not split loops rejected by processOneIterationLoop().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41194 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel
2007-08-20 20:24:15 +00:00
parent 94c510c631
commit d651f657f2
3 changed files with 13 additions and 9 deletions

View File

@@ -178,7 +178,7 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
// First see if it is possible to eliminate loop itself or not. // First see if it is possible to eliminate loop itself or not.
for (SmallVector<SplitInfo, 4>::iterator SI = SplitData.begin(), for (SmallVector<SplitInfo, 4>::iterator SI = SplitData.begin(),
E = SplitData.end(); SI != E; ++SI) { E = SplitData.end(); SI != E;) {
SplitInfo &SD = *SI; SplitInfo &SD = *SI;
if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) { if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) {
Changed = processOneIterationLoop(SD); Changed = processOneIterationLoop(SD);
@@ -186,8 +186,13 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
++NumIndexSplit; ++NumIndexSplit;
// If is loop is eliminated then nothing else to do here. // If is loop is eliminated then nothing else to do here.
return Changed; return Changed;
} else {
SmallVector<SplitInfo, 4>::iterator Delete_SI = SI;
++SI;
SplitData.erase(Delete_SI);
} }
} } else
++SI;
} }
unsigned MaxCost = 99; unsigned MaxCost = 99;
@@ -198,8 +203,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
SplitInfo SD = *SI; SplitInfo SD = *SI;
// ICM_EQs are already handled above. // ICM_EQs are already handled above.
if (SD.SplitCondition->getPredicate() == ICmpInst::ICMP_EQ) assert (SD.SplitCondition->getPredicate() != ICmpInst::ICMP_EQ &&
continue; "Unexpected split condition predicate");
unsigned Cost = findSplitCost(L, SD); unsigned Cost = findSplitCost(L, SD);
if (Cost < MaxCost) if (Cost < MaxCost)
@@ -207,7 +212,8 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
} }
// Split most profitiable condition. // Split most profitiable condition.
Changed = splitLoop(SplitData[MostProfitableSDIndex]); if (!SplitData.empty())
Changed = splitLoop(SplitData[MostProfitableSDIndex]);
if (Changed) if (Changed)
++NumIndexSplit; ++NumIndexSplit;

View File

@@ -1,5 +1,4 @@
; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \ ; RUN: llvm-as < %s | opt -loop-index-split -disable-output
; RUN: grep "loop-index-split" | count 1
%struct._edit_script = type { %struct._edit_script*, i32, i8 } %struct._edit_script = type { %struct._edit_script*, i32, i8 }

View File

@@ -1,5 +1,4 @@
; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \ ; RUN: llvm-as < %s | opt -loop-index-split -disable-output
; RUN: grep "loop-index-split" | count 1
%struct._edit_script = type { %struct._edit_script*, i32, i8 } %struct._edit_script = type { %struct._edit_script*, i32, i8 }