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

Jan Patrick Lehr via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 03:42:23 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:

Why do we check here again? Isn't this a legality check and should already be handled in `canVectorize`?

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


More information about the llvm-commits mailing list