[PATCH] D111350: [LoopFlatten] Mark inner loop as deleted
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 8 13:04:00 PDT 2021
nikic updated this revision to Diff 378341.
nikic edited the summary of this revision.
nikic added a comment.
Always invalidate, independently of LoopNestMode.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111350/new/
https://reviews.llvm.org/D111350
Files:
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
Index: llvm/lib/Transforms/Scalar/LoopFlatten.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -606,7 +606,7 @@
static bool DoFlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI,
ScalarEvolution *SE, AssumptionCache *AC,
- const TargetTransformInfo *TTI) {
+ const TargetTransformInfo *TTI, LPMUpdater *U) {
Function *F = FI.OuterLoop->getHeader()->getParent();
LLVM_DEBUG(dbgs() << "Checks all passed, doing the transformation\n");
{
@@ -662,6 +662,8 @@
// deleted, and any information that have about the outer loop invalidated.
SE->forgetLoop(FI.OuterLoop);
SE->forgetLoop(FI.InnerLoop);
+ if (U)
+ U->markLoopAsDeleted(*FI.InnerLoop, FI.InnerLoop->getName());
LI->erase(FI.InnerLoop);
// Increment statistic value.
@@ -737,7 +739,7 @@
static bool FlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI,
ScalarEvolution *SE, AssumptionCache *AC,
- const TargetTransformInfo *TTI) {
+ const TargetTransformInfo *TTI, LPMUpdater *U) {
LLVM_DEBUG(
dbgs() << "Loop flattening running on outer loop "
<< FI.OuterLoop->getHeader()->getName() << " and inner loop "
@@ -766,7 +768,7 @@
// If we have widened and can perform the transformation, do that here.
if (CanFlatten)
- return DoFlattenLoopPair(FI, DT, LI, SE, AC, TTI);
+ return DoFlattenLoopPair(FI, DT, LI, SE, AC, TTI, U);
// Otherwise, if we haven't widened the IV, check if the new iteration
// variable might overflow. In this case, we need to version the loop, and
@@ -784,18 +786,18 @@
}
LLVM_DEBUG(dbgs() << "Multiply cannot overflow, modifying loop in-place\n");
- return DoFlattenLoopPair(FI, DT, LI, SE, AC, TTI);
+ return DoFlattenLoopPair(FI, DT, LI, SE, AC, TTI, U);
}
bool Flatten(LoopNest &LN, DominatorTree *DT, LoopInfo *LI, ScalarEvolution *SE,
- AssumptionCache *AC, TargetTransformInfo *TTI) {
+ AssumptionCache *AC, TargetTransformInfo *TTI, LPMUpdater *U) {
bool Changed = false;
for (Loop *InnerLoop : LN.getLoops()) {
auto *OuterLoop = InnerLoop->getParentLoop();
if (!OuterLoop)
continue;
FlattenInfo FI(OuterLoop, InnerLoop);
- Changed |= FlattenLoopPair(FI, DT, LI, SE, AC, TTI);
+ Changed |= FlattenLoopPair(FI, DT, LI, SE, AC, TTI, U);
}
return Changed;
}
@@ -810,7 +812,7 @@
// in simplified form, and also needs LCSSA. Running
// this pass will simplify all loops that contain inner loops,
// regardless of whether anything ends up being flattened.
- Changed |= Flatten(LN, &AR.DT, &AR.LI, &AR.SE, &AR.AC, &AR.TTI);
+ Changed |= Flatten(LN, &AR.DT, &AR.LI, &AR.SE, &AR.AC, &AR.TTI, &U);
if (!Changed)
return PreservedAnalyses::all();
@@ -860,7 +862,7 @@
bool Changed = false;
for (Loop *L : *LI) {
auto LN = LoopNest::getLoopNest(*L, *SE);
- Changed |= Flatten(*LN, DT, LI, SE, AC, TTI);
+ Changed |= Flatten(*LN, DT, LI, SE, AC, TTI, nullptr);
}
return Changed;
}
Index: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -281,8 +281,6 @@
/// state, this routine will mark that the current loop should be skipped by
/// the rest of the pass management infrastructure.
void markLoopAsDeleted(Loop &L, llvm::StringRef Name) {
- assert((!LoopNestMode || CurrentL == &L) &&
- "L should be a top-level loop in loop-nest mode.");
LAM.clear(L, Name);
assert((&L == CurrentL || CurrentL->contains(&L)) &&
"Cannot delete a loop outside of the "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111350.378341.patch
Type: text/x-patch
Size: 3977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211008/ffb3572f/attachment.bin>
More information about the llvm-commits
mailing list