[llvm] [AMDGPU] Extended vector promotion to aggregate types. (PR #143784)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 11 15:05:39 PDT 2025
================
@@ -818,6 +818,28 @@ static BasicBlock::iterator skipToNonAllocaInsertPt(BasicBlock &BB,
return I;
}
+/// Get the underlying type of a homogeneous aggregate type, or nullptr if the
+/// type is non-homogeneous.
+static Type *getHomogeneousType(Type *Ty) {
+ if (auto *VectorTy = dyn_cast<FixedVectorType>(Ty))
+ return VectorTy->getElementType();
+ if (auto *ArrayTy = dyn_cast<ArrayType>(Ty))
+ return getHomogeneousType(ArrayTy->getElementType());
+ if (auto *StructTy = dyn_cast<StructType>(Ty)) {
+ if (StructTy->getNumElements() == 0)
+ return nullptr;
+
+ auto *Iter = StructTy->element_begin();
+ Type *HTy = getHomogeneousType(*Iter);
+ for (; Iter != StructTy->element_end(); ++Iter)
+ if (getHomogeneousType(*Iter) != HTy)
+ return nullptr;
+
+ return HTy;
+ }
+ return Ty;
----------------
zGoldthorpe wrote:
For non-aggregate types, I figured `getHomogeneousType` should just return the type back. This won't affect the pass either way, though, since singletons won't get promoted to vectors anyway.
https://github.com/llvm/llvm-project/pull/143784
More information about the llvm-commits
mailing list