[clang] [llvm] [SROA] Canonicalize homogeneous structs into fixed vectors (PR #165159)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 24 07:25:39 PDT 2026
================
@@ -5130,6 +5130,162 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
return true;
}
+/// Try to canonicalize a homogeneous, tightly-packed struct to a vector type.
+///
+/// For structs where all elements have the same type and are tightly packed
+/// (no padding), we can represent them as a fixed vector which enables better
+/// optimization (e.g., vector selects instead of memcpy).
+///
+/// \param STy The struct type to try to canonicalize.
+/// \param DL The DataLayout for size/alignment queries.
+/// \returns The equivalent vector type, or nullptr if not applicable.
+static FixedVectorType *tryCanonicalizeStructToVector(StructType *STy,
----------------
yxsamliu wrote:
Yes, I moved it in that direction. I simplified the structural part of tryCanonicalizeStructToVector along those lines, and I also folded the conservative fallback decision into that same helper so the logic is not split across two separate functions anymore
https://github.com/llvm/llvm-project/pull/165159
More information about the cfe-commits
mailing list