mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Implement a todo, rewriting all possible scev expressions inside of the
loop. This eliminates the extra add from the previous case, but it's not clear that this will be a performance win overall. Tommorows test results will tell. :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13103 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4e5f03602c
commit
1363e85df7
@ -444,21 +444,31 @@ void IndVarSimplify::runOnLoop(Loop *L) {
|
|||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteTriviallyDeadInstructions(DeadInsts);
|
// Now replace all derived expressions in the loop body with simpler
|
||||||
|
// expressions.
|
||||||
// TODO: In the future we could replace all instructions in the loop body with
|
|
||||||
// simpler expressions. It's not clear how useful this would be though or if
|
|
||||||
// the code expansion cost would be worth it! We probably shouldn't do this
|
|
||||||
// until we have a way to reuse expressions already in the code.
|
|
||||||
#if 0
|
|
||||||
for (unsigned i = 0, e = L->getBlocks().size(); i != e; ++i)
|
for (unsigned i = 0, e = L->getBlocks().size(); i != e; ++i)
|
||||||
if (LI->getLoopFor(L->getBlocks()[i]) == L) { // Not in a subloop...
|
if (LI->getLoopFor(L->getBlocks()[i]) == L) { // Not in a subloop...
|
||||||
BasicBlock *BB = L->getBlocks()[i];
|
BasicBlock *BB = L->getBlocks()[i];
|
||||||
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
||||||
if (I->getType()->isInteger() && // Is an integer instruction
|
if (I->getType()->isInteger() && // Is an integer instruction
|
||||||
|
!I->use_empty() &&
|
||||||
!Rewriter.isInsertedInstruction(I)) {
|
!Rewriter.isInsertedInstruction(I)) {
|
||||||
SCEVHandle SH = SE->getSCEV(I);
|
SCEVHandle SH = SE->getSCEV(I);
|
||||||
|
Value *V = Rewriter.ExpandCodeFor(SH, I, I->getType());
|
||||||
|
if (V != I) {
|
||||||
|
if (isa<Instruction>(V)) {
|
||||||
|
std::string Name = I->getName();
|
||||||
|
I->setName("");
|
||||||
|
V->setName(Name);
|
||||||
|
}
|
||||||
|
I->replaceAllUsesWith(V);
|
||||||
|
DeadInsts.insert(I);
|
||||||
|
++NumRemoved;
|
||||||
|
Changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
DeleteTriviallyDeadInstructions(DeadInsts);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user