[llvm] [LV] Use vscale for tuning to improve branch weight estimates (PR #144733)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 05:07:06 PDT 2025


================
@@ -7326,9 +7326,11 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
                            OrigLoop->getHeader()->getContext());
   VPlanTransforms::runPass(VPlanTransforms::replicateByVF, BestVPlan, BestVF);
   VPlanTransforms::runPass(VPlanTransforms::materializeBroadcasts, BestVPlan);
-  if (hasBranchWeightMD(*OrigLoop->getLoopLatch()->getTerminator()))
+  if (hasBranchWeightMD(*OrigLoop->getLoopLatch()->getTerminator())) {
+    std::optional<unsigned> VScale = CM.getVScaleForTuning();
     VPlanTransforms::runPass(VPlanTransforms::addBranchWeightToMiddleTerminator,
-                             BestVPlan, BestVF);
+                             BestVPlan, BestVF, VScale);
----------------
david-arm wrote:

I think this is a good suggestion and I'll look at restructuring this in a follow-up patch!

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


More information about the llvm-commits mailing list