[llvm] [VPlan] Move initial skeleton construction earlier (NFC). (PR #150848)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 5 06:38:04 PDT 2025
================
@@ -516,35 +552,11 @@ void VPlanTransforms::prepareForVectorization(
assert((!HasUncountableEarlyExit || HandledUncountableEarlyExit) &&
"missed an uncountable exit that must be handled");
- // Create SCEV and VPValue for the trip count.
- // We use the symbolic max backedge-taken-count, which works also when
- // vectorizing loops with uncountable early exits.
- const SCEV *BackedgeTakenCountSCEV = PSE.getSymbolicMaxBackedgeTakenCount();
- assert(!isa<SCEVCouldNotCompute>(BackedgeTakenCountSCEV) &&
- "Invalid loop count");
- ScalarEvolution &SE = *PSE.getSE();
- const SCEV *TripCount = SE.getTripCountFromExitCount(BackedgeTakenCountSCEV,
- InductionTy, TheLoop);
- Plan.setTripCount(
- vputils::getOrCreateVPValueForSCEVExpr(Plan, TripCount, SE));
-
- VPBasicBlock *ScalarPH = Plan.createVPBasicBlock("scalar.ph");
- VPBlockUtils::connectBlocks(ScalarPH, Plan.getScalarHeader());
-
- // The connection order corresponds to the operands of the conditional branch,
- // with the middle block already connected to the exit block.
- VPBlockUtils::connectBlocks(MiddleVPBB, ScalarPH);
- // Also connect the entry block to the scalar preheader.
- // TODO: Also introduce a branch recipe together with the minimum trip count
- // check.
- VPBlockUtils::connectBlocks(Plan.getEntry(), ScalarPH);
- Plan.getEntry()->swapSuccessors();
-
// If MiddleVPBB has a single successor then the original loop does not exit
// via the latch and the single successor must be the scalar preheader.
----------------
fhahn wrote:
Yep, this should be taken care of by consistently emitting a check if VectorTC == TC. This is the most general, the others are optimizations of cases where we know the check is either always false or true.
https://github.com/llvm/llvm-project/pull/150848
More information about the llvm-commits
mailing list