// This transformation requires dominator and immediate dominator info
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
- AU.addRequired<DominatorSet>();
+ AU.addRequired<ETForest>();
AU.addRequired<DominatorTree>();
AU.addRequired<ValueNumbering>();
}
bool Changed = false;
// Get pointers to the analysis results that we will be using...
- DominatorSet &DS = getAnalysis<DominatorSet>();
+ ETForest &EF = getAnalysis<ETForest>();
ValueNumbering &VN = getAnalysis<ValueNumbering>();
DominatorTree &DT = getAnalysis<DominatorTree>();
if (OtherI->getParent() == BB)
Dominates = BlockInsts.count(OtherI);
else
- Dominates = DS.dominates(OtherI->getParent(), BB);
+ Dominates = EF.dominates(OtherI->getParent(), BB);
if (Dominates) {
// Okay, we found an instruction with the same value as this one
class LoopStrengthReduce : public FunctionPass {
LoopInfo *LI;
- DominatorSet *DS;
+ ETForest *EF;
ScalarEvolution *SE;
const TargetData *TD;
const Type *UIntPtrTy;
virtual bool runOnFunction(Function &) {
LI = &getAnalysis<LoopInfo>();
- DS = &getAnalysis<DominatorSet>();
+ EF = &getAnalysis<ETForest>();
SE = &getAnalysis<ScalarEvolution>();
TD = &getAnalysis<TargetData>();
UIntPtrTy = TD->getIntPtrType();
AU.addPreservedID(LoopSimplifyID);
AU.addPreserved<LoopInfo>();
AU.addPreserved<DominatorSet>();
+ AU.addPreserved<ETForest>();
AU.addPreserved<ImmediateDominators>();
AU.addPreserved<DominanceFrontier>();
AU.addPreserved<DominatorTree>();
AU.addRequiredID(LoopSimplifyID);
AU.addRequired<LoopInfo>();
- AU.addRequired<DominatorSet>();
+ AU.addRequired<ETForest>();
AU.addRequired<TargetData>();
AU.addRequired<ScalarEvolution>();
}
/// the loop, resulting in reg-reg copies (if we use the pre-inc value when we
/// should use the post-inc value).
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 (L->contains(User->getParent())) return false;
// Ok, the user is outside of the loop. If it is dominated by the latch
// block, use the post-inc value.
- if (DS->dominates(LatchBlock, User->getParent()))
+ if (EF->dominates(LatchBlock, User->getParent()))
return true;
// There is one case we have to be careful of: PHI nodes. These little guys
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
if (PN->getIncomingValue(i) == IV) {
++NumUses;
- if (!DS->dominates(LatchBlock, PN->getIncomingBlock(i)))
+ if (!EF->dominates(LatchBlock, PN->getIncomingBlock(i)))
return false;
}
// 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
// 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
// expecting, so subtract this off.
SCEVHandle NewStart = SCEV::getMinusSCEV(Start, Stride);