https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109543
--- Comment #5 from Richard Sandiford <rsandifo at gcc dot gnu.org> --- I think the loop in compute_mode_layout needs to be smarter for unions. At the moment it's sensitive to field order, which doesn't make much conceptual sense. E.g. for the admittedly contrived example: #include <arm_neon.h> union u1 { int32x2x2_t x; __int128 y __attribute__((packed)); }; union u2 { __attribute__((packed)) __int128 y; int32x2x2_t x; }; compiled with -mstrict-align, the loop produces V2x2SImode for union u1 (good!) but TImode for union u2 (requires too much alignment). That doesn't matter as things stand, since we don't accept unions with vector modes. But if we did, union u1 would be placed in registers and union u2 wouldn't.