[llvm] [VPlan] Hook IR blocks into VPlan during skeleton creation (NFC) (PR #114292)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 3 16:34:20 PST 2024
================
@@ -2428,6 +2428,32 @@ InnerLoopVectorizer::getOrCreateVectorTripCount(BasicBlock *InsertBlock) {
return VectorTripCount;
}
+/// Helper to connect both the vector and scalar preheaders to the Plan's
+/// entry. This is used when adjusting \p Plan during skeleton
+/// creation, i.e. adjusting the plan after introducing an initial runtime
+/// check.
+/// TODO: Connect scalar preheader during initial VPlan construction.
+static void connectScalarPreheaderAsBypassInVPlan(VPlan &Plan) {
+ VPBlockBase *VectorPH = Plan.getVectorPreheader();
+ VPBlockBase *ScalarPH = Plan.getScalarPreheader();
+ VPBlockBase *Entry = Plan.getEntry();
+ VPBlockUtils::connectBlocks(Entry, ScalarPH);
+ std::swap(Entry->getSuccessors()[0], Entry->getSuccessors()[1]);
----------------
ayalz wrote:
This swap better be done by VPBlockUtils, e.g., `VPBlockUtils::swapSuccessors(Entry)`. Ideally, the order of successors should be set atomically as part of introducing their conditional branch recipe. Or, if the conditional branch is a VPIRI and the successors are VPIRBB's, check the taken/fall-through IR blocks of the branch against those wrapped by the successor VPIRBB's, to detect if swapping is needed.
Are the non-const versions of getSuccessors (and getPredecessors) needed, better prevent external users from making such changes to them inconsistently?
https://github.com/llvm/llvm-project/pull/114292
More information about the llvm-commits
mailing list