[llvm] [SROA] adjust struct layout requirements for struct to vector canonicalization (PR #201967)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 24 00:54:03 PDT 2026
================
@@ -5125,9 +5126,20 @@ static FixedVectorType *tryCanonicalizeStructToVector(StructType *STy,
!IsIntegralPointerTy)
return nullptr;
+ // Ensure the struct is tightly packed so that the bit-layout is the same as
+ // the corresponding vector. For example, this prevents a miscompile for
+ // { i5, i5 }, which has padding after each i5 field, whereas <i5, i5> has
+ // tightly packed elements and trailing padding. So if you loaded an
+ // { i5, i5 } memory layout as <i5, i5> you wouldn't correctly load each
+ // element.
----------------
antoniofrighetto wrote:
```suggestion
// Ensure the struct is tightly packed so that the bit-layout is the same as
// the corresponding vector.
```
https://github.com/llvm/llvm-project/pull/201967
More information about the llvm-commits
mailing list