[PATCH] D114586: [VPlan] Verify plan entry and exit blocks, set correct exit block.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 25 05:38:30 PST 2021
fhahn created this revision.
fhahn added reviewers: Ayal, gilr, rengolin.
Herald added subscribers: tschuett, psnobl, rogfer01, bollu, hiraditya.
fhahn requested review of this revision.
Herald added a subscriber: vkmr.
Herald added a project: LLVM.
Both the entry and exit blocks of the top-region of a plan must be
VPBasicBlocks. They also must have no predecessors or successors
respectively.
This invariant was broken when splitting a block for sink-after. To fix
the issue, set the exit block of the region *after* sink-after is done.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D114586
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
Index: llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
+++ llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
@@ -156,5 +156,25 @@
RecipeI++;
}
}
+
+ const VPRegionBlock *TopRegion = cast<VPRegionBlock>(Plan.getEntry());
+ const VPBasicBlock *Entry = dyn_cast<VPBasicBlock>(TopRegion->getEntry());
+ if (!Entry) {
+ errs() << "VPlan entry block is not a VPBasicBlock\n";
+ return false;
+ }
+ if (Entry->getNumPredecessors() != 0) {
+ errs() << "VPlan entry block has predecessors\n";
+ return false;
+ }
+ const VPBasicBlock *Exit = dyn_cast<VPBasicBlock>(TopRegion->getExit());
+ if (!Exit) {
+ errs() << "VPlan exit block is not a VPBasicBlock\n";
+ return false;
+ }
+ if (Exit->getNumSuccessors() != 0) {
+ errs() << "VPlan exit block has successors\n";
+ return false;
+ }
return true;
}
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9560,7 +9560,6 @@
!Plan->getEntry()->getEntryBasicBlock()->empty() &&
"entry block must be set to a VPRegionBlock having a non-empty entry "
"VPBasicBlock");
- cast<VPRegionBlock>(Plan->getEntry())->setExit(VPBB);
RecipeBuilder.fixHeaderPhis();
// ---------------------------------------------------------------------------
@@ -9631,6 +9630,7 @@
}
}
+ cast<VPRegionBlock>(Plan->getEntry())->setExit(VPBB);
// Now that sink-after is done, move induction recipes for optimized truncates
// to the phi section of the header block.
for (VPWidenIntOrFpInductionRecipe *Ind : InductionsToMove)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114586.389752.patch
Type: text/x-patch
Size: 1843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211125/b64519c0/attachment.bin>
More information about the llvm-commits
mailing list