mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
Use 'continue' to reduce nesting in this loop. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51399 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ddc4ee82b5
commit
29d929363d
@ -787,72 +787,69 @@ void LICM::FindPromotableValuesInLoop(
|
|||||||
// We can promote this alias set if it has a store, if it is a "Must" alias
|
// We can promote this alias set if it has a store, if it is a "Must" alias
|
||||||
// set, if the pointer is loop invariant, and if we are not eliminating any
|
// set, if the pointer is loop invariant, and if we are not eliminating any
|
||||||
// volatile loads or stores.
|
// volatile loads or stores.
|
||||||
if (!AS.isForwardingAliasSet() && AS.isMod() && AS.isMustAlias() &&
|
if (AS.isForwardingAliasSet() || !AS.isMod() || !AS.isMustAlias() ||
|
||||||
!AS.isVolatile() && CurLoop->isLoopInvariant(AS.begin()->first)) {
|
AS.isVolatile() || !CurLoop->isLoopInvariant(AS.begin()->first))
|
||||||
assert(!AS.empty() &&
|
continue;
|
||||||
"Must alias set should have at least one pointer element in it!");
|
|
||||||
Value *V = AS.begin()->first;
|
|
||||||
|
|
||||||
// Check that all of the pointers in the alias set have the same type. We
|
assert(!AS.empty() &&
|
||||||
// cannot (yet) promote a memory location that is loaded and stored in
|
"Must alias set should have at least one pointer element in it!");
|
||||||
// different sizes.
|
Value *V = AS.begin()->first;
|
||||||
|
|
||||||
|
// Check that all of the pointers in the alias set have the same type. We
|
||||||
|
// cannot (yet) promote a memory location that is loaded and stored in
|
||||||
|
// different sizes.
|
||||||
|
{
|
||||||
bool PointerOk = true;
|
bool PointerOk = true;
|
||||||
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
|
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
|
||||||
if (V->getType() != I->first->getType()) {
|
if (V->getType() != I->first->getType()) {
|
||||||
PointerOk = false;
|
PointerOk = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!PointerOk)
|
||||||
// If one use of value V inside the loop is safe then it is OK to promote
|
continue;
|
||||||
// this value. On the otherside if there is not any unsafe use inside the
|
|
||||||
// loop then also it is OK to promote this value. Otherwise it is
|
|
||||||
// unsafe to promote this value.
|
|
||||||
if (PointerOk) {
|
|
||||||
bool oneSafeUse = false;
|
|
||||||
bool oneUnsafeUse = false;
|
|
||||||
for(Value::use_iterator UI = V->use_begin(), UE = V->use_end();
|
|
||||||
UI != UE; ++UI) {
|
|
||||||
Instruction *Use = dyn_cast<Instruction>(*UI);
|
|
||||||
if (!Use || !CurLoop->contains(Use->getParent()))
|
|
||||||
continue;
|
|
||||||
for (SmallVector<Instruction *, 4>::iterator
|
|
||||||
ExitI = LoopExits.begin(), ExitE = LoopExits.end();
|
|
||||||
ExitI != ExitE; ++ExitI) {
|
|
||||||
Instruction *Ex = *ExitI;
|
|
||||||
if (!isa<PHINode>(Use) && DT->dominates(Use, Ex)) {
|
|
||||||
oneSafeUse = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
oneUnsafeUse = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oneSafeUse)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oneSafeUse)
|
|
||||||
PointerOk = true;
|
|
||||||
else if (!oneUnsafeUse)
|
|
||||||
PointerOk = true;
|
|
||||||
else
|
|
||||||
PointerOk = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PointerOk) {
|
|
||||||
const Type *Ty = cast<PointerType>(V->getType())->getElementType();
|
|
||||||
AllocaInst *AI = new AllocaInst(Ty, 0, V->getName()+".tmp", FnStart);
|
|
||||||
PromotedValues.push_back(std::make_pair(AI, V));
|
|
||||||
|
|
||||||
// Update the AST and alias analysis.
|
|
||||||
CurAST->copyValue(V, AI);
|
|
||||||
|
|
||||||
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
|
|
||||||
ValueToAllocaMap.insert(std::make_pair(I->first, AI));
|
|
||||||
|
|
||||||
DOUT << "LICM: Promoting value: " << *V << "\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If one use of value V inside the loop is safe then it is OK to promote
|
||||||
|
// this value. On the otherside if there is not any unsafe use inside the
|
||||||
|
// loop then also it is OK to promote this value. Otherwise it is
|
||||||
|
// unsafe to promote this value.
|
||||||
|
bool oneSafeUse = false;
|
||||||
|
bool oneUnsafeUse = false;
|
||||||
|
for(Value::use_iterator UI = V->use_begin(), UE = V->use_end();
|
||||||
|
UI != UE; ++UI) {
|
||||||
|
Instruction *Use = dyn_cast<Instruction>(*UI);
|
||||||
|
if (!Use || !CurLoop->contains(Use->getParent()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (SmallVector<Instruction *, 4>::iterator
|
||||||
|
ExitI = LoopExits.begin(), ExitE = LoopExits.end();
|
||||||
|
ExitI != ExitE; ++ExitI) {
|
||||||
|
Instruction *Ex = *ExitI;
|
||||||
|
if (!isa<PHINode>(Use) && DT->dominates(Use, Ex)) {
|
||||||
|
oneSafeUse = true;
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
oneUnsafeUse = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oneSafeUse)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!oneSafeUse && oneUnsafeUse)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const Type *Ty = cast<PointerType>(V->getType())->getElementType();
|
||||||
|
AllocaInst *AI = new AllocaInst(Ty, 0, V->getName()+".tmp", FnStart);
|
||||||
|
PromotedValues.push_back(std::make_pair(AI, V));
|
||||||
|
|
||||||
|
// Update the AST and alias analysis.
|
||||||
|
CurAST->copyValue(V, AI);
|
||||||
|
|
||||||
|
for (AliasSet::iterator I = AS.begin(), E = AS.end(); I != E; ++I)
|
||||||
|
ValueToAllocaMap.insert(std::make_pair(I->first, AI));
|
||||||
|
|
||||||
|
DOUT << "LICM: Promoting value: " << *V << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user