mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
Use DominatorTree instead of ETForest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37499 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -111,7 +111,7 @@ namespace {
|
|||||||
|
|
||||||
class VISIBILITY_HIDDEN LoopStrengthReduce : public LoopPass {
|
class VISIBILITY_HIDDEN LoopStrengthReduce : public LoopPass {
|
||||||
LoopInfo *LI;
|
LoopInfo *LI;
|
||||||
ETForest *EF;
|
DominatorTree *DT;
|
||||||
ScalarEvolution *SE;
|
ScalarEvolution *SE;
|
||||||
const TargetData *TD;
|
const TargetData *TD;
|
||||||
const Type *UIntPtrTy;
|
const Type *UIntPtrTy;
|
||||||
@@ -156,13 +156,12 @@ namespace {
|
|||||||
// many analyses if they are around.
|
// many analyses if they are around.
|
||||||
AU.addPreservedID(LoopSimplifyID);
|
AU.addPreservedID(LoopSimplifyID);
|
||||||
AU.addPreserved<LoopInfo>();
|
AU.addPreserved<LoopInfo>();
|
||||||
AU.addPreserved<ETForest>();
|
|
||||||
AU.addPreserved<DominanceFrontier>();
|
AU.addPreserved<DominanceFrontier>();
|
||||||
AU.addPreserved<DominatorTree>();
|
AU.addPreserved<DominatorTree>();
|
||||||
|
|
||||||
AU.addRequiredID(LoopSimplifyID);
|
AU.addRequiredID(LoopSimplifyID);
|
||||||
AU.addRequired<LoopInfo>();
|
AU.addRequired<LoopInfo>();
|
||||||
AU.addRequired<ETForest>();
|
AU.addRequired<DominatorTree>();
|
||||||
AU.addRequired<TargetData>();
|
AU.addRequired<TargetData>();
|
||||||
AU.addRequired<ScalarEvolution>();
|
AU.addRequired<ScalarEvolution>();
|
||||||
}
|
}
|
||||||
@@ -353,7 +352,7 @@ static bool getSCEVStartAndStride(const SCEVHandle &SH, Loop *L,
|
|||||||
/// the loop, resulting in reg-reg copies (if we use the pre-inc value when we
|
/// the loop, resulting in reg-reg copies (if we use the pre-inc value when we
|
||||||
/// should use the post-inc value).
|
/// should use the post-inc value).
|
||||||
static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV,
|
static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV,
|
||||||
Loop *L, ETForest *EF, Pass *P) {
|
Loop *L, DominatorTree *DT, Pass *P) {
|
||||||
// If the user is in the loop, use the preinc value.
|
// If the user is in the loop, use the preinc value.
|
||||||
if (L->contains(User->getParent())) return false;
|
if (L->contains(User->getParent())) return false;
|
||||||
|
|
||||||
@@ -361,7 +360,7 @@ static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV,
|
|||||||
|
|
||||||
// Ok, the user is outside of the loop. If it is dominated by the latch
|
// Ok, the user is outside of the loop. If it is dominated by the latch
|
||||||
// block, use the post-inc value.
|
// block, use the post-inc value.
|
||||||
if (EF->dominates(LatchBlock, User->getParent()))
|
if (DT->dominates(LatchBlock, User->getParent()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// There is one case we have to be careful of: PHI nodes. These little guys
|
// There is one case we have to be careful of: PHI nodes. These little guys
|
||||||
@@ -378,7 +377,7 @@ static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV,
|
|||||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
||||||
if (PN->getIncomingValue(i) == IV) {
|
if (PN->getIncomingValue(i) == IV) {
|
||||||
++NumUses;
|
++NumUses;
|
||||||
if (!EF->dominates(LatchBlock, PN->getIncomingBlock(i)))
|
if (!DT->dominates(LatchBlock, PN->getIncomingBlock(i)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +455,7 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L,
|
|||||||
// Okay, we found a user that we cannot reduce. Analyze the instruction
|
// Okay, we found a user that we cannot reduce. Analyze the instruction
|
||||||
// and decide what to do with it. If we are a use inside of the loop, use
|
// and decide what to do with it. If we are a use inside of the loop, use
|
||||||
// the value before incrementation, otherwise use it after incrementation.
|
// the value before incrementation, otherwise use it after incrementation.
|
||||||
if (IVUseShouldUsePostIncValue(User, I, L, EF, this)) {
|
if (IVUseShouldUsePostIncValue(User, I, L, DT, this)) {
|
||||||
// The value used will be incremented by the stride more than we are
|
// The value used will be incremented by the stride more than we are
|
||||||
// expecting, so subtract this off.
|
// expecting, so subtract this off.
|
||||||
SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);
|
SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);
|
||||||
@@ -1400,7 +1399,7 @@ namespace {
|
|||||||
bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) {
|
bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||||
|
|
||||||
LI = &getAnalysis<LoopInfo>();
|
LI = &getAnalysis<LoopInfo>();
|
||||||
EF = &getAnalysis<ETForest>();
|
DT = &getAnalysis<DominatorTree>();
|
||||||
SE = &getAnalysis<ScalarEvolution>();
|
SE = &getAnalysis<ScalarEvolution>();
|
||||||
TD = &getAnalysis<TargetData>();
|
TD = &getAnalysis<TargetData>();
|
||||||
UIntPtrTy = TD->getIntPtrType();
|
UIntPtrTy = TD->getIntPtrType();
|
||||||
|
Reference in New Issue
Block a user