[llvm] [VPlan] Model first memory runtime checks as VPlan recipes. (PR #221483)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 15:47:52 PDT 2026
================
@@ -1459,54 +1460,6 @@ static void insertCheckBlockBeforeVectorLoop(VPlan &Plan,
addIncomingForLastPredecessor(ScalarPH);
}
-void VPlanTransforms::modelGeneratedMainLoopBlocks(
- VPlan &EpiPlan, VPlan &MainPlan, VPIRBasicBlock *EnteredFrom) {
- // Map blocks from MainPlan to new, empty VPIRBasicBlocks in EpiPlan, so the
- // skeleton CFG can be modeled explicitly. MainPlan's entry maps to EpiPlan's
- // now-disconnected entry and its scalar PH to EnteredFrom.
- VPBlockBase *MainEntry = MainPlan.getEntry();
- VPBlockBase *MainScalarPH = MainPlan.getScalarPreheader();
- SmallMapVector<VPBlockBase *, VPBlockBase *, 8> MainToEpiVPBB;
- MainToEpiVPBB[MainEntry] = EpiPlan.getEntry();
- ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
- MainEntry);
- for (VPIRBasicBlock *VPBB : VPBlockUtils::blocksAs<VPIRBasicBlock>(RPOT))
- // Skip entry block and exit blocks/scalar loop header; they are already
- // modeled in the epilogue plan.
- if (VPBB != MainEntry && VPBB != MainScalarPH && VPBB->hasSuccessors())
- MainToEpiVPBB[VPBB] =
- EpiPlan.createEmptyVPIRBasicBlock(VPBB->getIRBasicBlock());
- MainToEpiVPBB[MainScalarPH] = EnteredFrom;
-
- // First, connect the edges from the bypass blocks (minimum iteration checks,
- // runtime checks) to the scalar preheader, in reverse order, to preserve the
- // predecessor order of the generated IR.
- VPBasicBlock *EpiScalarPH = EpiPlan.getScalarPreheader();
- for (VPBlockBase *MainVPBB :
- reverse(drop_end(drop_begin(MainScalarPH->predecessors())))) {
- VPBlockUtils::connectBlocks(MainToEpiVPBB.lookup(MainVPBB), EpiScalarPH);
- addIncomingForLastPredecessor(EpiScalarPH);
- }
-
- // Mirror MainPlan's CFG, skipping the bypass edges connected above, which
- // come first, and edges to blocks not modeled in EpiPlan.
- for (auto &[MainVPBB, EpiVPBB] : drop_end(MainToEpiVPBB))
- for (VPBlockBase *Succ :
- drop_begin(MainVPBB->getSuccessors(), EpiVPBB->getNumSuccessors()))
- if (auto *SuccVPBB = MainToEpiVPBB.lookup(Succ))
- VPBlockUtils::connectBlocks(EpiVPBB, SuccVPBB);
-
- // EnteredFrom is the only modeled block with phis; re-use the incoming values
- // its IR phis already have for the new predecessors.
- for (VPRecipeBase &R : EnteredFrom->phis()) {
- auto *PhiR = cast<VPIRPhi>(&R);
----------------
artagnon wrote:
Hm, not sure how this change is related? Isn't this min-iteration-count-check, which is unrelated to mem-checks entirely?
https://github.com/llvm/llvm-project/pull/221483
More information about the llvm-commits
mailing list