[llvm] [SandboxVec][LoadStoreVec] Initial pass implementation (PR #188308)

Jan Patrick Lehr via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 01:21:36 PDT 2026


================
@@ -119,6 +124,35 @@ class VecUtils {
     }
     return FixedVectorType::get(ElemTy, NumElts);
   }
+  /// \Returns the combined vector type for \p Bndl, even when the element types
+  /// differ. For example: i8,i8,i16 will return <4 x i8>. \Returns null if
+  /// types are of mixed float/integer types.
+  static Type *getCombinedVectorTypeFor(ArrayRef<Instruction *> Bndl,
+                                        const DataLayout &DL) {
+    assert(!Bndl.empty() && "Expected non-empty Bndl!");
+    unsigned TotalBits = 0;
+    unsigned MinElmBits = std::numeric_limits<unsigned>::max();
+    Type *MinElmTy = nullptr;
+    bool LastIsFloat = false;
+    for (auto [Idx, V] : enumerate(Bndl)) {
+      Type *ElmTy = getElementType(Utils::getExpectedType(V));
+
+      // Reject mixed integer/float types.
+      bool IsFloat = ElmTy->isFloatingPointTy();
+      if (Idx != 0 && IsFloat != LastIsFloat)
+        return nullptr;
+      LastIsFloat = IsFloat;
----------------
jplehr wrote:

Right now, it should not make a difference because it does not support mixed types anyway, right?
As for whether the function should return a pair or an already constructed type, I don't know how much control users should or want to have. This seems to be a future-problem, so I would say let's leave it as is and reconsider when the need arises.

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


More information about the llvm-commits mailing list