[llvm] [VPlan] Improve code around ArrayRef construction (NFC) (PR #179191)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 2 01:43:41 PST 2026


https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/179191

None

>From ab0e3c911f63c3b6f24280627da8c16ebad7496f Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <artagnon at tenstorrent.com>
Date: Mon, 2 Feb 2026 09:37:39 +0000
Subject: [PATCH] [VPlan] Improve code around ArrayRef construction (NFC)

---
 llvm/lib/Transforms/Vectorize/VPlan.h | 45 ++++++++++++---------------
 1 file changed, 20 insertions(+), 25 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index ae6988d86e194..fd8d959c65df7 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1539,8 +1539,7 @@ class VPIRInstruction : public VPRecipeBase {
   /// VPIRInstruction::create() should be used to create VPIRInstructions, as
   /// subclasses may need to be created, e.g. VPIRPhi.
   VPIRInstruction(Instruction &I)
-      : VPRecipeBase(VPRecipeBase::VPIRInstructionSC, ArrayRef<VPValue *>()),
-        I(I) {}
+      : VPRecipeBase(VPRecipeBase::VPIRInstructionSC, {}), I(I) {}
 
 public:
   ~VPIRInstruction() override = default;
@@ -2006,8 +2005,8 @@ class VPVectorEndPointerRecipe : public VPRecipeWithIRFlags,
 public:
   VPVectorEndPointerRecipe(VPValue *Ptr, VPValue *VF, Type *SourceElementTy,
                            int64_t Stride, GEPNoWrapFlags GEPFlags, DebugLoc DL)
-      : VPRecipeWithIRFlags(VPRecipeBase::VPVectorEndPointerSC,
-                            ArrayRef<VPValue *>({Ptr, VF}), GEPFlags, DL),
+      : VPRecipeWithIRFlags(VPRecipeBase::VPVectorEndPointerSC, {Ptr, VF},
+                            GEPFlags, DL),
         SourceElementTy(SourceElementTy), Stride(Stride) {
     assert(Stride < 0 && "Stride must be negative");
   }
@@ -2142,8 +2141,7 @@ class LLVM_ABI_FOR_TEST VPHeaderPHIRecipe : public VPSingleDefRecipe,
 protected:
   VPHeaderPHIRecipe(unsigned char VPRecipeID, Instruction *UnderlyingInstr,
                     VPValue *Start, DebugLoc DL = DebugLoc::getUnknown())
-      : VPSingleDefRecipe(VPRecipeID, ArrayRef<VPValue *>({Start}),
-                          UnderlyingInstr, DL) {}
+      : VPSingleDefRecipe(VPRecipeID, Start, UnderlyingInstr, DL) {}
 
   const VPRecipeBase *getAsRecipe() const override { return this; }
 
@@ -2788,9 +2786,8 @@ class LLVM_ABI_FOR_TEST VPInterleaveBase : public VPRecipeBase,
   /// Return the VPValues stored by this interleave group. If it is a load
   /// interleave group, return an empty ArrayRef.
   ArrayRef<VPValue *> getStoredValues() const {
-    return ArrayRef<VPValue *>(op_end() -
-                                   (getNumStoreOperands() + (HasMask ? 1 : 0)),
-                               getNumStoreOperands());
+    return {op_end() - (getNumStoreOperands() + (HasMask ? 1 : 0)),
+            getNumStoreOperands()};
   }
 };
 
@@ -2843,10 +2840,10 @@ class LLVM_ABI_FOR_TEST VPInterleaveRecipe final : public VPInterleaveBase {
 class LLVM_ABI_FOR_TEST VPInterleaveEVLRecipe final : public VPInterleaveBase {
 public:
   VPInterleaveEVLRecipe(VPInterleaveRecipe &R, VPValue &EVL, VPValue *Mask)
-      : VPInterleaveBase(
-            VPRecipeBase::VPInterleaveEVLSC, R.getInterleaveGroup(),
-            ArrayRef<VPValue *>({R.getAddr(), &EVL}), R.getStoredValues(), Mask,
-            R.needsMaskForGaps(), R, R.getDebugLoc()) {
+      : VPInterleaveBase(VPRecipeBase::VPInterleaveEVLSC,
+                         R.getInterleaveGroup(), {R.getAddr(), &EVL},
+                         R.getStoredValues(), Mask, R.needsMaskForGaps(), R,
+                         R.getDebugLoc()) {
     assert(!getInterleaveGroup()->isReverse() &&
            "Reversed interleave-group with tail folding is not supported.");
     assert(!needsMaskForGaps() && "Interleaved access with gap mask is not "
@@ -2918,15 +2915,13 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
                     VPValue *ChainOp, VPValue *VecOp, VPValue *CondOp,
                     ReductionStyle Style, DebugLoc DL = DebugLoc::getUnknown())
       : VPReductionRecipe(VPRecipeBase::VPReductionSC, RdxKind, FMFs, I,
-                          ArrayRef<VPValue *>({ChainOp, VecOp}), CondOp, Style,
-                          DL) {}
+                          {ChainOp, VecOp}, CondOp, Style, DL) {}
 
   VPReductionRecipe(const RecurKind RdxKind, FastMathFlags FMFs,
                     VPValue *ChainOp, VPValue *VecOp, VPValue *CondOp,
                     ReductionStyle Style, DebugLoc DL = DebugLoc::getUnknown())
       : VPReductionRecipe(VPRecipeBase::VPReductionSC, RdxKind, FMFs, nullptr,
-                          ArrayRef<VPValue *>({ChainOp, VecOp}), CondOp, Style,
-                          DL) {}
+                          {ChainOp, VecOp}, CondOp, Style, DL) {}
 
   ~VPReductionRecipe() override = default;
 
@@ -3006,12 +3001,12 @@ class LLVM_ABI_FOR_TEST VPReductionEVLRecipe : public VPReductionRecipe {
 public:
   VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp,
                        DebugLoc DL = DebugLoc::getUnknown())
-      : VPReductionRecipe(
-            VPRecipeBase::VPReductionEVLSC, R.getRecurrenceKind(),
-            R.getFastMathFlags(),
-            cast_or_null<Instruction>(R.getUnderlyingValue()),
-            ArrayRef<VPValue *>({R.getChainOp(), R.getVecOp(), &EVL}), CondOp,
-            getReductionStyle(/*InLoop=*/true, R.isOrdered(), 1), DL) {}
+      : VPReductionRecipe(VPRecipeBase::VPReductionEVLSC, R.getRecurrenceKind(),
+                          R.getFastMathFlags(),
+                          cast_or_null<Instruction>(R.getUnderlyingValue()),
+                          {R.getChainOp(), R.getVecOp(), &EVL}, CondOp,
+                          getReductionStyle(/*InLoop=*/true, R.isOrdered(), 1),
+                          DL) {}
 
   ~VPReductionEVLRecipe() override = default;
 
@@ -3910,8 +3905,8 @@ class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags {
   VPScalarIVStepsRecipe(VPValue *IV, VPValue *Step, VPValue *VF,
                         Instruction::BinaryOps Opcode, FastMathFlags FMFs,
                         DebugLoc DL)
-      : VPRecipeWithIRFlags(VPRecipeBase::VPScalarIVStepsSC,
-                            ArrayRef<VPValue *>({IV, Step, VF}), FMFs, DL),
+      : VPRecipeWithIRFlags(VPRecipeBase::VPScalarIVStepsSC, {IV, Step, VF},
+                            FMFs, DL),
         InductionOpcode(Opcode) {}
 
   VPScalarIVStepsRecipe(const InductionDescriptor &IndDesc, VPValue *IV,



More information about the llvm-commits mailing list