forked from OSchip/llvm-project
Cleanup. Make ScalarEvolution an explicit argument of the
SimplifyIndVar utility since it is required. llvm-svn: 137202
This commit is contained in:
parent
9a877fef91
commit
e629d008fb
|
@ -39,18 +39,18 @@ public:
|
||||||
|
|
||||||
/// simplifyUsersOfIV - Simplify instructions that use this induction variable
|
/// simplifyUsersOfIV - Simplify instructions that use this induction variable
|
||||||
/// by using ScalarEvolution to analyze the IV's recurrence.
|
/// by using ScalarEvolution to analyze the IV's recurrence.
|
||||||
bool simplifyUsersOfIV(PHINode *CurrIV, LPPassManager *LPM,
|
bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, LPPassManager *LPM,
|
||||||
SmallVectorImpl<WeakVH> &Dead, IVVisitor *V = NULL);
|
SmallVectorImpl<WeakVH> &Dead, IVVisitor *V = NULL);
|
||||||
|
|
||||||
/// SimplifyLoopIVs - Simplify users of induction variables within this
|
/// SimplifyLoopIVs - Simplify users of induction variables within this
|
||||||
/// loop. This does not actually change or add IVs.
|
/// loop. This does not actually change or add IVs.
|
||||||
bool simplifyLoopIVs(Loop *L, LPPassManager *LPM,
|
bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, LPPassManager *LPM,
|
||||||
SmallVectorImpl<WeakVH> &Dead);
|
SmallVectorImpl<WeakVH> &Dead);
|
||||||
|
|
||||||
/// simplifyIVUsers - Simplify instructions recorded by the IVUsers pass.
|
/// simplifyIVUsers - Simplify instructions recorded by the IVUsers pass.
|
||||||
/// This is a legacy implementation to reproduce the behavior of the
|
/// This is a legacy implementation to reproduce the behavior of the
|
||||||
/// IndVarSimplify pass prior to DisableIVRewrite.
|
/// IndVarSimplify pass prior to DisableIVRewrite.
|
||||||
bool simplifyIVUsers(IVUsers *IU, LPPassManager *LPM,
|
bool simplifyIVUsers(IVUsers *IU, ScalarEvolution *SE, LPPassManager *LPM,
|
||||||
SmallVectorImpl<WeakVH> &Dead);
|
SmallVectorImpl<WeakVH> &Dead);
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
|
@ -1192,7 +1192,7 @@ void IndVarSimplify::SimplifyAndExtend(Loop *L,
|
||||||
// Information about sign/zero extensions of CurrIV.
|
// Information about sign/zero extensions of CurrIV.
|
||||||
WideIVVisitor WIV(SE, TD);
|
WideIVVisitor WIV(SE, TD);
|
||||||
|
|
||||||
Changed |= simplifyUsersOfIV(CurrIV, &LPM, DeadInsts, &WIV);
|
Changed |= simplifyUsersOfIV(CurrIV, SE, &LPM, DeadInsts, &WIV);
|
||||||
|
|
||||||
if (WIV.WI.WidestNativeType) {
|
if (WIV.WI.WidestNativeType) {
|
||||||
WideIVMap[CurrIV] = WIV.WI;
|
WideIVMap[CurrIV] = WIV.WI;
|
||||||
|
@ -1831,7 +1831,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||||
|
|
||||||
// Eliminate redundant IV users.
|
// Eliminate redundant IV users.
|
||||||
if (!DisableIVRewrite)
|
if (!DisableIVRewrite)
|
||||||
Changed |= simplifyIVUsers(IU, &LPM, DeadInsts);
|
Changed |= simplifyIVUsers(IU, SE, &LPM, DeadInsts);
|
||||||
|
|
||||||
// Eliminate redundant IV cycles.
|
// Eliminate redundant IV cycles.
|
||||||
if (DisableIVRewrite)
|
if (DisableIVRewrite)
|
||||||
|
|
|
@ -54,16 +54,16 @@ namespace {
|
||||||
bool Changed;
|
bool Changed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimplifyIndvar(Loop *Loop, LPPassManager *LPM,
|
SimplifyIndvar(Loop *Loop, ScalarEvolution *SE, LPPassManager *LPM,
|
||||||
SmallVectorImpl<WeakVH> &Dead, IVUsers *IVU = NULL) :
|
SmallVectorImpl<WeakVH> &Dead, IVUsers *IVU = NULL) :
|
||||||
L(Loop),
|
L(Loop),
|
||||||
LI(LPM->getAnalysisIfAvailable<LoopInfo>()),
|
LI(LPM->getAnalysisIfAvailable<LoopInfo>()),
|
||||||
SE(LPM->getAnalysisIfAvailable<ScalarEvolution>()),
|
SE(SE),
|
||||||
IU(IVU),
|
IU(IVU),
|
||||||
TD(LPM->getAnalysisIfAvailable<TargetData>()),
|
TD(LPM->getAnalysisIfAvailable<TargetData>()),
|
||||||
DeadInsts(Dead),
|
DeadInsts(Dead),
|
||||||
Changed(false) {
|
Changed(false) {
|
||||||
assert(LI && SE && "IV simplification requires ScalarEvolution");
|
assert(LI && "IV simplification requires LoopInfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasChanged() const { return Changed; }
|
bool hasChanged() const { return Changed; }
|
||||||
|
@ -372,22 +372,22 @@ namespace llvm {
|
||||||
|
|
||||||
/// simplifyUsersOfIV - Simplify instructions that use this induction variable
|
/// simplifyUsersOfIV - Simplify instructions that use this induction variable
|
||||||
/// by using ScalarEvolution to analyze the IV's recurrence.
|
/// by using ScalarEvolution to analyze the IV's recurrence.
|
||||||
bool simplifyUsersOfIV(PHINode *CurrIV, LPPassManager *LPM,
|
bool simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, LPPassManager *LPM,
|
||||||
SmallVectorImpl<WeakVH> &Dead, IVVisitor *V)
|
SmallVectorImpl<WeakVH> &Dead, IVVisitor *V)
|
||||||
{
|
{
|
||||||
LoopInfo *LI = &LPM->getAnalysis<LoopInfo>();
|
LoopInfo *LI = &LPM->getAnalysis<LoopInfo>();
|
||||||
SimplifyIndvar SIV(LI->getLoopFor(CurrIV->getParent()), LPM, Dead);
|
SimplifyIndvar SIV(LI->getLoopFor(CurrIV->getParent()), SE, LPM, Dead);
|
||||||
SIV.simplifyUsers(CurrIV, V);
|
SIV.simplifyUsers(CurrIV, V);
|
||||||
return SIV.hasChanged();
|
return SIV.hasChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// simplifyLoopIVs - Simplify users of induction variables within this
|
/// simplifyLoopIVs - Simplify users of induction variables within this
|
||||||
/// loop. This does not actually change or add IVs.
|
/// loop. This does not actually change or add IVs.
|
||||||
bool simplifyLoopIVs(Loop *L, LPPassManager *LPM,
|
bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, LPPassManager *LPM,
|
||||||
SmallVectorImpl<WeakVH> &Dead) {
|
SmallVectorImpl<WeakVH> &Dead) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ++I) {
|
for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ++I) {
|
||||||
Changed |= simplifyUsersOfIV(cast<PHINode>(I), LPM, Dead);
|
Changed |= simplifyUsersOfIV(cast<PHINode>(I), SE, LPM, Dead);
|
||||||
}
|
}
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
@ -397,9 +397,9 @@ bool simplifyLoopIVs(Loop *L, LPPassManager *LPM,
|
||||||
///
|
///
|
||||||
/// This is the old approach to IV simplification to be replaced by
|
/// This is the old approach to IV simplification to be replaced by
|
||||||
/// SimplifyLoopIVs.
|
/// SimplifyLoopIVs.
|
||||||
bool simplifyIVUsers(IVUsers *IU, LPPassManager *LPM,
|
bool simplifyIVUsers(IVUsers *IU, ScalarEvolution *SE, LPPassManager *LPM,
|
||||||
SmallVectorImpl<WeakVH> &Dead) {
|
SmallVectorImpl<WeakVH> &Dead) {
|
||||||
SimplifyIndvar SIV(IU->getLoop(), LPM, Dead);
|
SimplifyIndvar SIV(IU->getLoop(), SE, LPM, Dead);
|
||||||
|
|
||||||
// Each round of simplification involves a round of eliminating operations
|
// Each round of simplification involves a round of eliminating operations
|
||||||
// followed by a round of widening IVs. A single IVUsers worklist is used
|
// followed by a round of widening IVs. A single IVUsers worklist is used
|
||||||
|
|
Loading…
Reference in New Issue