[llvm] [VPlan] Add VPReplicateRecipe::operandsWithoutMask() (NFC). (PR #202115)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 7 02:46:33 PDT 2026


https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/202115

Add a helper to access a VPReplicateRecipe's operands while excluding the mask of a predicated recipe, and use it in createReplicateRegion.

Split off from https://github.com/llvm/llvm-project/pull/201676.

>From 49f5d1eaaf924911decd8e13fa863d07a00df3d4 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Sun, 7 Jun 2026 11:40:03 +0200
Subject: [PATCH] [VPlan] Add VPReplicateRecipe::operandsWithoutMask() (NFC).

Add a helper to access a VPReplicateRecipe's operands while excluding the
mask of a predicated recipe, and use it in createReplicateRegion.
---
 llvm/lib/Transforms/Vectorize/VPlan.h             | 5 +++++
 llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index eb43f384a7c9d..71080705a1c6e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3481,6 +3481,11 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags,
     return getOperand(getNumOperands() - 1);
   }
 
+  /// Return the recipe's operands, excluding the mask of a predicated recipe.
+  operand_range operandsWithoutMask() {
+    return isPredicated() ? drop_end(operands()) : operands();
+  }
+
   unsigned getOpcode() const { return getUnderlyingInstr()->getOpcode(); }
 
 protected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index c2afae9ccca8c..bd292e22135a9 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -529,7 +529,7 @@ static VPRegionBlock *createReplicateRegion(VPReplicateRecipe *PredRecipe,
   // Replace predicated replicate recipe with a replicate recipe without a
   // mask but in the replicate region.
   auto *RecipeWithoutMask = new VPReplicateRecipe(
-      PredRecipe->getUnderlyingInstr(), drop_end(PredRecipe->operands()),
+      PredRecipe->getUnderlyingInstr(), PredRecipe->operandsWithoutMask(),
       PredRecipe->isSingleScalar(), nullptr /*Mask*/, *PredRecipe, *PredRecipe,
       PredRecipe->getDebugLoc());
   auto *Pred =



More information about the llvm-commits mailing list