forked from OSchip/llvm-project
Revert "[LoopNest][LoopFlatten] Change LoopFlattenPass to LoopNest pass"
This reverts commit ffc4d3e068
.
This commit is contained in:
parent
e493abcf55
commit
7e06cf8f1b
|
@ -24,7 +24,8 @@ class LoopFlattenPass : public PassInfoMixin<LoopFlattenPass> {
|
||||||
public:
|
public:
|
||||||
LoopFlattenPass() = default;
|
LoopFlattenPass() = default;
|
||||||
|
|
||||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
|
PreservedAnalyses run(LoopNest &LN, LoopAnalysisManager &LAM,
|
||||||
|
LoopStandardAnalysisResults &AR, LPMUpdater &U);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
|
@ -616,7 +616,7 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
|
||||||
FPM.addPass(SimplifyCFGPass());
|
FPM.addPass(SimplifyCFGPass());
|
||||||
FPM.addPass(InstCombinePass());
|
FPM.addPass(InstCombinePass());
|
||||||
if (EnableLoopFlatten)
|
if (EnableLoopFlatten)
|
||||||
FPM.addPass(LoopFlattenPass());
|
FPM.addPass(createFunctionToLoopPassAdaptor(LoopFlattenPass()));
|
||||||
// The loop passes in LPM2 (LoopFullUnrollPass) do not preserve MemorySSA.
|
// The loop passes in LPM2 (LoopFullUnrollPass) do not preserve MemorySSA.
|
||||||
// *All* loop passes must preserve it, in order to be able to use it.
|
// *All* loop passes must preserve it, in order to be able to use it.
|
||||||
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM2),
|
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM2),
|
||||||
|
@ -791,7 +791,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
|
||||||
FPM.addPass(SimplifyCFGPass());
|
FPM.addPass(SimplifyCFGPass());
|
||||||
FPM.addPass(InstCombinePass());
|
FPM.addPass(InstCombinePass());
|
||||||
if (EnableLoopFlatten)
|
if (EnableLoopFlatten)
|
||||||
FPM.addPass(LoopFlattenPass());
|
FPM.addPass(createFunctionToLoopPassAdaptor(LoopFlattenPass()));
|
||||||
// The loop passes in LPM2 (LoopIdiomRecognizePass, IndVarSimplifyPass,
|
// The loop passes in LPM2 (LoopIdiomRecognizePass, IndVarSimplifyPass,
|
||||||
// LoopDeletionPass and LoopFullUnrollPass) do not preserve MemorySSA.
|
// LoopDeletionPass and LoopFullUnrollPass) do not preserve MemorySSA.
|
||||||
// *All* loop passes must preserve it, in order to be able to use it.
|
// *All* loop passes must preserve it, in order to be able to use it.
|
||||||
|
@ -1841,7 +1841,7 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
|
||||||
|
|
||||||
// More loops are countable; try to optimize them.
|
// More loops are countable; try to optimize them.
|
||||||
if (EnableLoopFlatten && Level.getSpeedupLevel() > 1)
|
if (EnableLoopFlatten && Level.getSpeedupLevel() > 1)
|
||||||
MainFPM.addPass(LoopFlattenPass());
|
MainFPM.addPass(createFunctionToLoopPassAdaptor(LoopFlattenPass()));
|
||||||
|
|
||||||
if (EnableConstraintElimination)
|
if (EnableConstraintElimination)
|
||||||
MainFPM.addPass(ConstraintEliminationPass());
|
MainFPM.addPass(ConstraintEliminationPass());
|
||||||
|
|
|
@ -247,7 +247,7 @@ FUNCTION_PASS("guard-widening", GuardWideningPass())
|
||||||
FUNCTION_PASS("load-store-vectorizer", LoadStoreVectorizerPass())
|
FUNCTION_PASS("load-store-vectorizer", LoadStoreVectorizerPass())
|
||||||
FUNCTION_PASS("loop-simplify", LoopSimplifyPass())
|
FUNCTION_PASS("loop-simplify", LoopSimplifyPass())
|
||||||
FUNCTION_PASS("loop-sink", LoopSinkPass())
|
FUNCTION_PASS("loop-sink", LoopSinkPass())
|
||||||
FUNCTION_PASS("loop-flatten", LoopFlattenPass())
|
FUNCTION_PASS("loop-unroll-and-jam", LoopUnrollAndJamPass())
|
||||||
FUNCTION_PASS("lowerinvoke", LowerInvokePass())
|
FUNCTION_PASS("lowerinvoke", LowerInvokePass())
|
||||||
FUNCTION_PASS("lowerswitch", LowerSwitchPass())
|
FUNCTION_PASS("lowerswitch", LowerSwitchPass())
|
||||||
FUNCTION_PASS("mem2reg", PromotePass())
|
FUNCTION_PASS("mem2reg", PromotePass())
|
||||||
|
@ -388,6 +388,7 @@ LOOP_PASS("canon-freeze", CanonicalizeFreezeInLoopsPass())
|
||||||
LOOP_PASS("dot-ddg", DDGDotPrinterPass())
|
LOOP_PASS("dot-ddg", DDGDotPrinterPass())
|
||||||
LOOP_PASS("invalidate<all>", InvalidateAllAnalysesPass())
|
LOOP_PASS("invalidate<all>", InvalidateAllAnalysesPass())
|
||||||
LOOP_PASS("licm", LICMPass())
|
LOOP_PASS("licm", LICMPass())
|
||||||
|
LOOP_PASS("loop-flatten", LoopFlattenPass())
|
||||||
LOOP_PASS("loop-idiom", LoopIdiomRecognizePass())
|
LOOP_PASS("loop-idiom", LoopIdiomRecognizePass())
|
||||||
LOOP_PASS("loop-instsimplify", LoopInstSimplifyPass())
|
LOOP_PASS("loop-instsimplify", LoopInstSimplifyPass())
|
||||||
LOOP_PASS("loop-interchange", LoopInterchangePass())
|
LOOP_PASS("loop-interchange", LoopInterchangePass())
|
||||||
|
|
|
@ -658,10 +658,10 @@ static bool FlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI,
|
||||||
return DoFlattenLoopPair(FI, DT, LI, SE, AC, TTI);
|
return DoFlattenLoopPair(FI, DT, LI, SE, AC, TTI);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Flatten(DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE,
|
bool Flatten(LoopNest &LN, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE,
|
||||||
AssumptionCache *AC, TargetTransformInfo *TTI) {
|
AssumptionCache *AC, TargetTransformInfo *TTI) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
for (auto *InnerLoop : LI->getLoopsInPreorder()) {
|
for (Loop *InnerLoop : LN.getLoops()) {
|
||||||
auto *OuterLoop = InnerLoop->getParentLoop();
|
auto *OuterLoop = InnerLoop->getParentLoop();
|
||||||
if (!OuterLoop)
|
if (!OuterLoop)
|
||||||
continue;
|
continue;
|
||||||
|
@ -671,13 +671,9 @@ bool Flatten(DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE,
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
PreservedAnalyses LoopFlattenPass::run(Function &F,
|
PreservedAnalyses LoopFlattenPass::run(LoopNest &LN, LoopAnalysisManager &LAM,
|
||||||
FunctionAnalysisManager &AM) {
|
LoopStandardAnalysisResults &AR,
|
||||||
auto *DT = &AM.getResult<DominatorTreeAnalysis>(F);
|
LPMUpdater &U) {
|
||||||
auto *LI = &AM.getResult<LoopAnalysis>(F);
|
|
||||||
auto *SE = &AM.getResult<ScalarEvolutionAnalysis>(F);
|
|
||||||
auto *AC = &AM.getResult<AssumptionAnalysis>(F);
|
|
||||||
auto *TTI = &AM.getResult<TargetIRAnalysis>(F);
|
|
||||||
|
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
|
|
||||||
|
@ -685,15 +681,7 @@ PreservedAnalyses LoopFlattenPass::run(Function &F,
|
||||||
// in simplified form, and also needs LCSSA. Running
|
// in simplified form, and also needs LCSSA. Running
|
||||||
// this pass will simplify all loops that contain inner loops,
|
// this pass will simplify all loops that contain inner loops,
|
||||||
// regardless of whether anything ends up being flattened.
|
// regardless of whether anything ends up being flattened.
|
||||||
for (const auto &L : *LI) {
|
Changed |= Flatten(LN, &AR.DT, &AR.LI, &AR.SE, &AR.AC, &AR.TTI);
|
||||||
if (L->isInnermost())
|
|
||||||
continue;
|
|
||||||
Changed |=
|
|
||||||
simplifyLoop(L, DT, LI, SE, AC, nullptr, false /* PreserveLCSSA */);
|
|
||||||
Changed |= formLCSSARecursively(*L, *DT, LI, SE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Changed |= Flatten(DT, LI, SE, AC, TTI);
|
|
||||||
|
|
||||||
if (!Changed)
|
if (!Changed)
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
|
@ -740,5 +728,10 @@ bool LoopFlattenLegacyPass::runOnFunction(Function &F) {
|
||||||
auto &TTIP = getAnalysis<TargetTransformInfoWrapperPass>();
|
auto &TTIP = getAnalysis<TargetTransformInfoWrapperPass>();
|
||||||
auto *TTI = &TTIP.getTTI(F);
|
auto *TTI = &TTIP.getTTI(F);
|
||||||
auto *AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
|
auto *AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
|
||||||
return Flatten(DT, LI, SE, AC, TTI);
|
bool Changed = false;
|
||||||
|
for (Loop *L : *LI) {
|
||||||
|
auto LN = LoopNest::getLoopNest(*L, *SE);
|
||||||
|
Changed |= Flatten(*LN, DT, LI, SE, AC, TTI);
|
||||||
|
}
|
||||||
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue