mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Do not ignore iv uses outside the loop.
This one slipped through cracks very well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56284 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -111,6 +111,10 @@ namespace {
|
||||
/// instruction then loop body is executed only for one iteration. In
|
||||
/// such case eliminate loop structure surrounding this loop body. For
|
||||
bool processOneIterationLoop(SplitInfo &SD);
|
||||
|
||||
/// isOneIterationLoop - Return true if split condition is EQ and
|
||||
/// the IV is not used outside the loop.
|
||||
bool isOneIterationLoop(ICmpInst *CI);
|
||||
|
||||
void updateLoopBounds(ICmpInst *CI);
|
||||
/// updateLoopIterationSpace - Current loop body is covered by an AND
|
||||
@ -248,7 +252,7 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
|
||||
SI = SplitData.erase(Delete_SI);
|
||||
}
|
||||
}
|
||||
else if (CI && CI->getPredicate() == ICmpInst::ICMP_EQ) {
|
||||
else if (isOneIterationLoop(CI)) {
|
||||
Changed = processOneIterationLoop(SD);
|
||||
if (Changed) {
|
||||
++NumIndexSplit;
|
||||
@ -276,6 +280,22 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
/// isOneIterationLoop - Return true if split condition is EQ and
|
||||
/// the IV is not used outside the loop.
|
||||
bool LoopIndexSplit::isOneIterationLoop(ICmpInst *CI) {
|
||||
if (!CI)
|
||||
return false;
|
||||
if (CI->getPredicate() != ICmpInst::ICMP_EQ)
|
||||
return false;
|
||||
|
||||
Value *Incr = IndVar->getIncomingValueForBlock(L->getLoopLatch());
|
||||
for (Value::use_iterator UI = Incr->use_begin(), E = Incr->use_end();
|
||||
UI != E; ++UI)
|
||||
if (!L->contains(cast<Instruction>(*UI)->getParent()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
/// Return true if V is a induction variable or induction variable's
|
||||
/// increment for loop L.
|
||||
void LoopIndexSplit::findIndVar(Value *V, Loop *L) {
|
||||
|
Reference in New Issue
Block a user