[llvm] [SandboxVec][LoadStoreVec] Support constant vectors of mixed types (PR #224890)
Anshil Gandhi via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 6 21:46:27 PDT 2026
================
@@ -170,20 +171,28 @@ class VecUtils {
const DataLayout &DL) {
assert(!Bndl.empty() && "Expected non-empty Bndl!");
unsigned TotalBits = 0;
+ unsigned GCDBits = 0;
unsigned MinElmBits = std::numeric_limits<unsigned>::max();
Type *MinElmTy = nullptr;
for (T *V : Bndl) {
Type *ElmTy = getElementType(Utils::getExpectedType(V));
unsigned ElmBits = Utils::getNumBits(ElmTy, DL);
TotalBits += ElmBits * VecUtils::getNumLanes(V);
+ GCDBits = std::gcd(GCDBits, ElmBits);
if (ElmBits < MinElmBits) {
MinElmBits = ElmBits;
MinElmTy = ElmTy;
}
}
- unsigned NumElms = TotalBits / MinElmBits;
- return FixedVectorType::get(MinElmTy, NumElms);
+ // The GCD is the size of the narrowest type unless it does not divide the
+ // rest, like i24 and i32, in which case no type in Bndl has that size and
+ // we fall back to an integer.
+ Type *VecElmTy = GCDBits == MinElmBits
+ ? MinElmTy
+ : IntegerType::get(MinElmTy->getContext(), GCDBits);
----------------
gandhi56 wrote:
We use MinElmTy here for cases such as {float, float, i32}, to avoid casting all elements into an integer type.
https://github.com/llvm/llvm-project/pull/224890
More information about the llvm-commits
mailing list