[VPlan] Retrieve vector trip count from BranchOnCount (NFC).

In preparePlanForMainVectorLoop, the vector trip count may already be
materialized, e.g. when narrowing interleave groups. VPSymbolicValues
should not be accessed after materializing. Instead retrieve the trip
count directly from the branch-on-count. This is NFC at the moment, but
is needed to tighten VPSymbolicValue access verification.
This commit is contained in:
Florian Hahn 2026-02-18 21:08:33 +00:00
parent a6e8de7407
commit cb87d346b4
No known key found for this signature in database
GPG Key ID: C8B0D7090F9127E6

View File

@ -9069,11 +9069,17 @@ static void preparePlanForMainVectorLoop(VPlan &MainPlan, VPlan &EpiPlan) {
AddFreezeForFindLastIVReductions(MainPlan, true);
AddFreezeForFindLastIVReductions(EpiPlan, false);
VPBasicBlock *MainScalarPH = MainPlan.getScalarPreheader();
VPValue *VectorTC = &MainPlan.getVectorTripCount();
VPValue *VectorTC = nullptr;
auto *Term =
MainPlan.getVectorLoopRegion()->getExitingBasicBlock()->getTerminator();
[[maybe_unused]] bool MatchedTC =
match(Term, m_BranchOnCount(m_VPValue(), m_VPValue(VectorTC)));
assert(MatchedTC && "must match vector trip count");
// If there is a suitable resume value for the canonical induction in the
// scalar (which will become vector) epilogue loop, use it and move it to the
// beginning of the scalar preheader. Otherwise create it below.
VPBasicBlock *MainScalarPH = MainPlan.getScalarPreheader();
auto ResumePhiIter =
find_if(MainScalarPH->phis(), [VectorTC](VPRecipeBase &R) {
return match(&R, m_VPInstruction<Instruction::PHI>(m_Specific(VectorTC),