[llvm] [SandboxVec][NFC] Replace ArrayRef witn BndlRef (PR #224077)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 09:53:19 PDT 2026


https://github.com/vporpo created https://github.com/llvm/llvm-project/pull/224077

None

>From 6bf62ed24162e49faca90c2942804366b14603e3 Mon Sep 17 00:00:00 2001
From: Vasileios Porpodas <vasileios.porpodas at amd.com>
Date: Wed, 16 Sep 2026 01:13:47 +0000
Subject: [PATCH] [SandboxVec][NFC] Replace ArrayRef witn BndlRef

---
 .../Vectorize/SandboxVectorizer/DependencyGraph.h      |  3 ++-
 .../Transforms/Vectorize/SandboxVectorizer/Legality.h  | 10 +++++-----
 .../Vectorize/SandboxVectorizer/Passes/LoadStoreVec.h  | 10 +++++-----
 .../Transforms/Vectorize/SandboxVectorizer/Scheduler.h |  2 +-
 .../Vectorize/SandboxVectorizer/DependencyGraph.cpp    |  3 +--
 .../Vectorize/SandboxVectorizer/Legality.cpp           |  7 +++----
 .../SandboxVectorizer/Passes/LoadStoreVec.cpp          | 10 +++++-----
 .../Vectorize/SandboxVectorizer/Scheduler.cpp          |  2 +-
 8 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
index 8f39c4258bb61..c4c971a79578b 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h
@@ -29,6 +29,7 @@
 #include "llvm/SandboxIR/IntrinsicInst.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Interval.h"
+#include "llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h"
 
 namespace llvm::sandboxir {
 
@@ -561,7 +562,7 @@ class DependencyGraph {
   }
   /// Build/extend the dependency graph such that it includes \p Instrs. Returns
   /// the range of instructions added to the DAG.
-  LLVM_ABI Interval<Instruction> extend(ArrayRef<Instruction *> Instrs);
+  LLVM_ABI Interval<Instruction> extend(BndlRef<Instruction *> Instrs);
   /// \Returns the range of instructions included in the DAG.
   Interval<Instruction> getInterval() const { return DAGInterval; }
   void clear() {
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
index 1b3f71b5f0500..e4519fb7e1ec7 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
@@ -322,7 +322,7 @@ class LegalityAnalysis {
   /// Checks opcodes, types and other IR-specifics and returns a ResultReason
   /// object if not vectorizable, or nullptr otherwise.
   std::optional<ResultReason>
-  notVectorizableBasedOnOpcodesAndTypes(ArrayRef<Value *> Bndl);
+  notVectorizableBasedOnOpcodesAndTypes(BndlRef<Value *> Bndl);
 
   ScalarEvolution &SE;
   const DataLayout &DL;
@@ -331,7 +331,7 @@ class LegalityAnalysis {
   /// Finds how we can collect the values in \p Bndl from the vectorized or
   /// non-vectorized code. It returns a map of the value we should extract from
   /// and the corresponding shuffle mask we need to use.
-  CollectDescr getHowToCollectValues(ArrayRef<Value *> Bndl) const;
+  CollectDescr getHowToCollectValues(BndlRef<Value *> Bndl) const;
 
 public:
   LegalityAnalysis(AAResults &AA, ScalarEvolution &SE, const DataLayout &DL,
@@ -347,7 +347,7 @@ class LegalityAnalysis {
 
   /// \returns true if \p Instrs are in different blocks.
   template <typename ValueT>
-  static bool differentBlock(ArrayRef<ValueT *> Instrs) {
+  static bool differentBlock(BndlRef<ValueT *> Instrs) {
     auto *BB0 = cast<Instruction>(Instrs[0])->getParent();
     return any_of(drop_begin(Instrs), [BB0](auto *V) {
       return cast<Instruction>(V)->getParent() != BB0;
@@ -355,7 +355,7 @@ class LegalityAnalysis {
   }
 
   /// \returns true if all values in \p Values are unique.
-  template <typename ValueT> static bool areUnique(ArrayRef<ValueT *> Values) {
+  template <typename ValueT> static bool areUnique(BndlRef<ValueT *> Values) {
     SmallPtrSet<Value *, 8> Unique(llvm::from_range, Values);
     return Unique.size() == Values.size();
   }
@@ -364,7 +364,7 @@ class LegalityAnalysis {
   /// \Returns a LegalityResult object owned by LegalityAnalysis.
   /// \p SkipScheduling skips the scheduler check and is only meant for testing.
   // TODO: Try to remove the SkipScheduling argument by refactoring the tests.
-  LLVM_ABI const LegalityResult &canVectorize(ArrayRef<Value *> Bndl,
+  LLVM_ABI const LegalityResult &canVectorize(BndlRef<Value *> Bndl,
                                               bool SkipScheduling = false);
   /// \Returns a Pack with reason 'ForcePackForDebugging'.
   const LegalityResult &getForcedPackForDebugging() {
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.h
index 44d2704b194fa..7f2eb5cd032c1 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.h
@@ -55,22 +55,22 @@ class LLVM_ABI LoadStoreVec final : public RegionPass {
 
   /// Checks legality of vectorization and \returns the vector type on success,
   /// nullopt otherwise.
-  std::optional<Type *> canVectorize(ArrayRef<Instruction *> Bndl);
+  std::optional<Type *> canVectorize(BndlRef<Instruction *> Bndl);
 
   /// Builds a single vector load out of \p Loads. \returns the new load,
   /// or nullptr if \p Loads are not a vectorizable.
-  LoadInst *createVectorLoad(ArrayRef<Instruction *> Loads);
+  LoadInst *createVectorLoad(BndlRef<Instruction *> Loads);
 
   /// Builds a ConstantVector from per-lane constant store operands in \p
   /// Constants. \returns the packed ConstantVector.
-  Value *createConstantVector(ArrayRef<Value *> Constants);
+  Value *createConstantVector(BndlRef<Value *> Constants);
 
   /// Vectorizes \p Stores and their operands if constants or consecutive
   /// loads. \returns true on success.
-  bool vectorizeStores(ArrayRef<Instruction *> Stores, Region &Rgn);
+  bool vectorizeStores(BndlRef<Instruction *> Stores, Region &Rgn);
 
   /// Vectorizes \p Loads into a single load. \return the packed load.
-  LoadInst *vectorizeLoads(ArrayRef<Instruction *> Loads, Region &Rgn);
+  LoadInst *vectorizeLoads(BndlRef<Instruction *> Loads, Region &Rgn);
 
 public:
   LoadStoreVec(StringRef AuxArg) : RegionPass("load-store-vec") {
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h
index 9cbf5aa7899e7..6fcb440157b46 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h
@@ -406,7 +406,7 @@ class Scheduler {
   /// dependencies among \p Instrs. This function may involve scheduling
   /// intermediate instructions or canceling and re-scheduling if needed.
   /// \Returns true on success, false otherwise.
-  LLVM_ABI bool trySchedule(ArrayRef<Instruction *> Instrs);
+  LLVM_ABI bool trySchedule(BndlRef<Instruction *> Instrs);
   /// Clear the scheduler's state, including the DAG.
   void clear() {
     Bndls.clear();
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp
index 1ac84df828075..ed4fb3484ef36 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/DependencyGraph.h"
-#include "llvm/ADT/ArrayRef.h"
 #include "llvm/SandboxIR/Instruction.h"
 #include "llvm/SandboxIR/Utils.h"
 #include "llvm/Transforms/Vectorize/SandboxVectorizer/Scheduler.h"
@@ -650,7 +649,7 @@ void DependencyGraph::notifySetUse(const Use &U, Value *NewSrc) {
   }
 }
 
-Interval<Instruction> DependencyGraph::extend(ArrayRef<Instruction *> Instrs) {
+Interval<Instruction> DependencyGraph::extend(BndlRef<Instruction *> Instrs) {
   if (Instrs.empty())
     return {};
 
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
index d939c9c5f0d14..05201ff502997 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Legality.cpp
@@ -30,8 +30,7 @@ void LegalityResult::dump() const {
 #endif // NDEBUG
 
 std::optional<ResultReason>
-LegalityAnalysis::notVectorizableBasedOnOpcodesAndTypes(
-    ArrayRef<Value *> Bndl) {
+LegalityAnalysis::notVectorizableBasedOnOpcodesAndTypes(BndlRef<Value *> Bndl) {
   auto *I0 = cast<Instruction>(Bndl[0]);
   auto Opcode = I0->getOpcode();
   // If they have different opcodes, then we cannot form a vector (for now).
@@ -196,7 +195,7 @@ LegalityAnalysis::notVectorizableBasedOnOpcodesAndTypes(
 }
 
 CollectDescr
-LegalityAnalysis::getHowToCollectValues(ArrayRef<Value *> Bndl) const {
+LegalityAnalysis::getHowToCollectValues(BndlRef<Value *> Bndl) const {
   SmallVector<CollectDescr::ExtractElementDescr, 4> Vec;
   Vec.reserve(Bndl.size());
   for (auto [Elm, V] : enumerate(Bndl)) {
@@ -214,7 +213,7 @@ LegalityAnalysis::getHowToCollectValues(ArrayRef<Value *> Bndl) const {
   return CollectDescr(std::move(Vec));
 }
 
-const LegalityResult &LegalityAnalysis::canVectorize(ArrayRef<Value *> Bndl,
+const LegalityResult &LegalityAnalysis::canVectorize(BndlRef<Value *> Bndl,
                                                      bool SkipScheduling) {
   // If Bndl contains values other than instructions, we need to Pack.
   if (any_of(Bndl, [](auto *V) { return !isa<Instruction>(V); }))
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.cpp
index ddea7e62cfbf7..32759c62bbc3c 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Passes/LoadStoreVec.cpp
@@ -27,7 +27,7 @@ namespace sandboxir {
 
 #define DEBUG_PREFIX_LOCAL DEBUG_PREFIX "LoadStoreVec: "
 
-std::optional<Type *> LoadStoreVec::canVectorize(ArrayRef<Instruction *> Bndl) {
+std::optional<Type *> LoadStoreVec::canVectorize(BndlRef<Instruction *> Bndl) {
   // Check if in the same BB.
   if (LegalityAnalysis::differentBlock(Bndl))
     return std::nullopt;
@@ -67,7 +67,7 @@ bool LoadStoreVec::acceptOrRevert() {
   return true;
 }
 
-LoadInst *LoadStoreVec::createVectorLoad(ArrayRef<Instruction *> Loads) {
+LoadInst *LoadStoreVec::createVectorLoad(BndlRef<Instruction *> Loads) {
   if (!VecUtils::areConsecutive<LoadInst, Instruction>(
           Loads, A->getScalarEvolution(), *DL))
     return nullptr;
@@ -82,7 +82,7 @@ LoadInst *LoadStoreVec::createVectorLoad(ArrayRef<Instruction *> Loads) {
   return LoadInst::create(Ty, LdPtr, LdAlign, LdWhereIt, *Ctx, "VecIinitL");
 }
 
-Value *LoadStoreVec::createConstantVector(ArrayRef<Value *> Operands) {
+Value *LoadStoreVec::createConstantVector(BndlRef<Value *> Operands) {
   SmallVector<Constant *, 8> Constants;
   Constants.reserve(Operands.size());
   for (Value *Op : Operands) {
@@ -120,7 +120,7 @@ Value *LoadStoreVec::createConstantVector(ArrayRef<Value *> Operands) {
   return ConstantVector::get(Constants);
 }
 
-bool LoadStoreVec::vectorizeStores(ArrayRef<Instruction *> Stores,
+bool LoadStoreVec::vectorizeStores(BndlRef<Instruction *> Stores,
                                    Region &Rgn) {
   if (!VecUtils::areConsecutive<StoreInst, Instruction>(
           Stores, A->getScalarEvolution(), *DL))
@@ -187,7 +187,7 @@ bool LoadStoreVec::vectorizeStores(ArrayRef<Instruction *> Stores,
   return acceptOrRevert();
 }
 
-LoadInst *LoadStoreVec::vectorizeLoads(ArrayRef<Instruction *> Loads,
+LoadInst *LoadStoreVec::vectorizeLoads(BndlRef<Instruction *> Loads,
                                        Region &Rgn) {
   if (!VecUtils::areConsecutive<LoadInst, Instruction>(
           Loads, A->getScalarEvolution(), *DL))
diff --git a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp
index ff79bb69f7505..9559bdd93d65f 100644
--- a/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp
+++ b/llvm/lib/Transforms/Vectorize/SandboxVectorizer/Scheduler.cpp
@@ -451,7 +451,7 @@ void Scheduler::assertSameDirection(ArrayRef<Instruction *> Instrs) const {
 }
 #endif // NDEBUG
 
-bool Scheduler::trySchedule(ArrayRef<Instruction *> Instrs) {
+bool Scheduler::trySchedule(BndlRef<Instruction *> Instrs) {
   assert(all_of(drop_begin(Instrs),
                 [Instrs](Instruction *I) {
                   return I->getParent() == (*Instrs.begin())->getParent();



More information about the llvm-commits mailing list