[llvm] [VPlan] Cost truncated widened inductions via ::computeCost. (PR #212786)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 30 02:13:54 PDT 2026


================
@@ -5672,26 +5675,23 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
   auto TC = getSmallConstantTripCount(PSE.getSE(), OrigLoop);
   bool IsFullyUnrolled = TC == VF && !Plan.hasTailFolded();
   SmallPtrSet<const Value *, 4> WidenedIVs;
-  bool HasTruncatedIV = false;
   if (IsFullyUnrolled) {
     addFullyUnrolledInstructionsToIgnore(OrigLoop, Legal->getInductionVars(),
                                          CostCtx.SkipCostComputation);
   } else {
     // Inductions represented by a VPWidenIntOrFpInductionRecipe have their cost
     // computed by the recipe, so collect their phis to skip the legacy
-    // increment cost below. If any induction is truncated the VPlan-based cost
-    // will diverge. Still fall back to the legacy cost model for now.
-    VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
-    for (VPRecipeBase &R : *LoopRegion->getEntryBasicBlock())
-      if (auto *WideIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R)) {
-        HasTruncatedIV |= WideIV->getTruncInst() != nullptr;
-        if (PHINode *IVPhi = WideIV->getPHINode())
-          WidenedIVs.insert(IVPhi);
-      }
+    // increment cost below.
+    if (VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion())
----------------
fhahn wrote:

This change is not needed and just come back after a rebase mistake on my end after landing https://github.com/llvm/llvm-project/pull/202232 which had the simplificaiton. Gone now, thanks

https://github.com/llvm/llvm-project/pull/212786


More information about the llvm-commits mailing list