mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Switch these to using ETForest instead of DominatorSet to compute itself.
Patch written by Daniel Berlin! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
19ef3d5be2
commit
88cac3d2f7
@ -45,7 +45,7 @@ namespace {
|
|||||||
// This transformation requires dominator and immediate dominator info
|
// This transformation requires dominator and immediate dominator info
|
||||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||||
AU.setPreservesCFG();
|
AU.setPreservesCFG();
|
||||||
AU.addRequired<DominatorSet>();
|
AU.addRequired<ETForest>();
|
||||||
AU.addRequired<DominatorTree>();
|
AU.addRequired<DominatorTree>();
|
||||||
AU.addRequired<ValueNumbering>();
|
AU.addRequired<ValueNumbering>();
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ bool GCSE::runOnFunction(Function &F) {
|
|||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
// Get pointers to the analysis results that we will be using...
|
// Get pointers to the analysis results that we will be using...
|
||||||
DominatorSet &DS = getAnalysis<DominatorSet>();
|
ETForest &EF = getAnalysis<ETForest>();
|
||||||
ValueNumbering &VN = getAnalysis<ValueNumbering>();
|
ValueNumbering &VN = getAnalysis<ValueNumbering>();
|
||||||
DominatorTree &DT = getAnalysis<DominatorTree>();
|
DominatorTree &DT = getAnalysis<DominatorTree>();
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ bool GCSE::runOnFunction(Function &F) {
|
|||||||
if (OtherI->getParent() == BB)
|
if (OtherI->getParent() == BB)
|
||||||
Dominates = BlockInsts.count(OtherI);
|
Dominates = BlockInsts.count(OtherI);
|
||||||
else
|
else
|
||||||
Dominates = DS.dominates(OtherI->getParent(), BB);
|
Dominates = EF.dominates(OtherI->getParent(), BB);
|
||||||
|
|
||||||
if (Dominates) {
|
if (Dominates) {
|
||||||
// Okay, we found an instruction with the same value as this one
|
// Okay, we found an instruction with the same value as this one
|
||||||
|
@ -77,7 +77,7 @@ namespace {
|
|||||||
|
|
||||||
class LoopStrengthReduce : public FunctionPass {
|
class LoopStrengthReduce : public FunctionPass {
|
||||||
LoopInfo *LI;
|
LoopInfo *LI;
|
||||||
DominatorSet *DS;
|
ETForest *EF;
|
||||||
ScalarEvolution *SE;
|
ScalarEvolution *SE;
|
||||||
const TargetData *TD;
|
const TargetData *TD;
|
||||||
const Type *UIntPtrTy;
|
const Type *UIntPtrTy;
|
||||||
@ -111,7 +111,7 @@ namespace {
|
|||||||
|
|
||||||
virtual bool runOnFunction(Function &) {
|
virtual bool runOnFunction(Function &) {
|
||||||
LI = &getAnalysis<LoopInfo>();
|
LI = &getAnalysis<LoopInfo>();
|
||||||
DS = &getAnalysis<DominatorSet>();
|
EF = &getAnalysis<ETForest>();
|
||||||
SE = &getAnalysis<ScalarEvolution>();
|
SE = &getAnalysis<ScalarEvolution>();
|
||||||
TD = &getAnalysis<TargetData>();
|
TD = &getAnalysis<TargetData>();
|
||||||
UIntPtrTy = TD->getIntPtrType();
|
UIntPtrTy = TD->getIntPtrType();
|
||||||
@ -129,13 +129,14 @@ namespace {
|
|||||||
AU.addPreservedID(LoopSimplifyID);
|
AU.addPreservedID(LoopSimplifyID);
|
||||||
AU.addPreserved<LoopInfo>();
|
AU.addPreserved<LoopInfo>();
|
||||||
AU.addPreserved<DominatorSet>();
|
AU.addPreserved<DominatorSet>();
|
||||||
|
AU.addPreserved<ETForest>();
|
||||||
AU.addPreserved<ImmediateDominators>();
|
AU.addPreserved<ImmediateDominators>();
|
||||||
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<DominatorSet>();
|
AU.addRequired<ETForest>();
|
||||||
AU.addRequired<TargetData>();
|
AU.addRequired<TargetData>();
|
||||||
AU.addRequired<ScalarEvolution>();
|
AU.addRequired<ScalarEvolution>();
|
||||||
}
|
}
|
||||||
@ -324,7 +325,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, DominatorSet *DS, Pass *P) {
|
Loop *L, ETForest *EF, 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;
|
||||||
|
|
||||||
@ -332,7 +333,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 (DS->dominates(LatchBlock, User->getParent()))
|
if (EF->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
|
||||||
@ -349,7 +350,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 (!DS->dominates(LatchBlock, PN->getIncomingBlock(i)))
|
if (!EF->dominates(LatchBlock, PN->getIncomingBlock(i)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,7 +416,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, DS, this)) {
|
if (IVUseShouldUsePostIncValue(User, I, L, EF, 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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user