[llvm] [VPlan] Model branch cond to enter scalar epilogue in VPlan. (PR #92651)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 23 03:59:18 PDT 2024
================
@@ -7458,6 +7403,21 @@ LoopVectorizationPlanner::executePlan(
std::tie(State.CFG.PrevBB, CanonicalIVStartValue) =
ILV.createVectorizedLoopSkeleton(ExpandedSCEVs ? *ExpandedSCEVs
: State.ExpandedSCEVs);
+#ifdef EXPENSIVE_CHECKS
+ assert(DT->verify(DominatorTree::VerificationLevel::Fast));
+#endif
+
+ VPBasicBlock *MiddleVPBB =
+ cast<VPBasicBlock>(BestVPlan.getVectorLoopRegion()->getSingleSuccessor());
+
+ using namespace llvm::VPlanPatternMatch;
+ if (MiddleVPBB->begin() != MiddleVPBB->end() &&
+ match(&MiddleVPBB->back(), m_BranchOnCond(m_VPValue()))) {
+ cast<VPIRBasicBlock>(MiddleVPBB->getSuccessors()[1])
+ ->resetBlock(OrigLoop->getLoopPreheader());
----------------
fhahn wrote:
I m not sure if there's a better way at the moment. For now, we rely on the structure of the created middle block and it's successors: single successor must be to the scalar ph, 2 successors meas the second one is the scalar ph; if tail folding it will still have 2 successors, but <true> as condition. Added a comment.
https://github.com/llvm/llvm-project/pull/92651
More information about the llvm-commits
mailing list