[llvm] [VPlan] Preserve the branch weights of scalarized selects. (PR #224968)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 01:41:10 PDT 2026


================
@@ -527,6 +527,13 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan) {
            vp_depth_first_deep(Plan.getEntry()))) {
     for (VPRecipeBase &R : make_early_inc_range(*VPBB)) {
       VPBuilder Builder(&R);
+      // !prof is only supported on scalar selects.
+      if (auto *Widen = dyn_cast<VPWidenRecipe>(&R)) {
+        if (Widen->getOpcode() == Instruction::Select &&
+            !vputils::isSingleScalar(Widen->getOperand(0)))
+          Widen->eraseMetadata(LLVMContext::MD_prof);
----------------
david-arm wrote:

I don't understand why we're erasing the data here. It feels a bit unnatural because surely VPWidenRecipe is already a concrete recipe? Wouldn't it be more accurate to do this in a transform function purely related to processing of metadata?

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


More information about the llvm-commits mailing list