[llvm] [VPlan] Eliminate some vec temps with ArrayRef (NFC) (PR #207432)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 02:46:55 PDT 2026


https://github.com/artagnon updated https://github.com/llvm/llvm-project/pull/207432

>From d39e32eb8456ed5e9f66e805c94615be27936017 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Mon, 22 Jun 2026 20:21:19 +0100
Subject: [PATCH 1/3] [VPlan] Eliminate some vec temps with ArrayRef (NFC)

The enabling change is e56187575 ([ArrayRef] Make iterator_range
constructor const-agnostic, #205183).
---
 llvm/lib/Transforms/Vectorize/VPlan.h          | 3 +++
 llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 8 +++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 5e722efcf17fa..207ae15883756 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3468,6 +3468,9 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags,
   operand_range operandsWithoutMask() {
     return isPredicated() ? drop_end(operands()) : operands();
   }
+  const_operand_range operandsWithoutMask() const {
+    return isPredicated() ? drop_end(operands()) : operands();
+  }
 
   /// Returns the number of operands, excluding the mask if the recipe is
   /// predicated.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index b19559ae3cfdc..a0fc635838efe 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2307,8 +2307,7 @@ InstructionCost VPWidenIntrinsicRecipe::computeCallCost(
 
 InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,
                                                     VPCostContext &Ctx) const {
-  SmallVector<const VPValue *> ArgOps(operands());
-  return computeCallCost(VectorIntrinsicID, ArgOps, *this, VF, Ctx);
+  return computeCallCost(VectorIntrinsicID, operands(), *this, VF, Ctx);
 }
 
 StringRef VPWidenIntrinsicRecipe::getIntrinsicName() const {
@@ -3797,9 +3796,8 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
     auto *CalledFn =
         cast<Function>(getOperand(getNumOperands() - 1)->getLiveInIRValue());
     Type *ResultTy = this->getScalarType();
-    SmallVector<const VPValue *> ArgOps(drop_end(operands()));
-    return computeCallCost(CalledFn, ResultTy, ArgOps, isSingleScalar(), VF,
-                           Ctx);
+    return computeCallCost(CalledFn, ResultTy, operandsWithoutMask(),
+                           isSingleScalar(), VF, Ctx);
   }
   case Instruction::Add:
   case Instruction::Sub:

>From 21fa372dc179a398e5a637f5361bf85402af8d5f Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Thu, 9 Jul 2026 09:38:34 +0100
Subject: [PATCH 2/3] [VPlan] Fix major thinko, thanks Luke!

---
 llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index a0fc635838efe..8b29c3e44dc34 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -3796,7 +3796,7 @@ InstructionCost VPReplicateRecipe::computeCost(ElementCount VF,
     auto *CalledFn =
         cast<Function>(getOperand(getNumOperands() - 1)->getLiveInIRValue());
     Type *ResultTy = this->getScalarType();
-    return computeCallCost(CalledFn, ResultTy, operandsWithoutMask(),
+    return computeCallCost(CalledFn, ResultTy, drop_end(operands()),
                            isSingleScalar(), VF, Ctx);
   }
   case Instruction::Add:

>From 1fa6df8e772b6af6782844499ea0b0fa1ffce23e Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Thu, 9 Jul 2026 10:45:02 +0100
Subject: [PATCH 3/3] [VPlan] Strip dead code

---
 llvm/lib/Transforms/Vectorize/VPlan.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 207ae15883756..5e722efcf17fa 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3468,9 +3468,6 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags,
   operand_range operandsWithoutMask() {
     return isPredicated() ? drop_end(operands()) : operands();
   }
-  const_operand_range operandsWithoutMask() const {
-    return isPredicated() ? drop_end(operands()) : operands();
-  }
 
   /// Returns the number of operands, excluding the mask if the recipe is
   /// predicated.



More information about the llvm-commits mailing list