https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124637
--- Comment #25 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:b9fe0227183712d5ea65d58bf127f95bfd51eaea commit r16-9383-gb9fe0227183712d5ea65d58bf127f95bfd51eaea Author: Roger Sayle <[email protected]> Date: Fri May 8 21:06:54 2026 +0100 PR middle-end/124637: Fix passing padded constant structs in registers on big-endian targets This patch resolves PR middle-end/124637, a wrong code regression when passing a struct as a register on big-endian targets. On big-endian targets, store_constructor fills fields from the most significant bits, so for structs narrower than word size, any padding is incorrectly placed in the least significant bytes. This issue is fixed (on affected targets) by using a (unsigned) right shift on the value determined by store_constructor to correctly align the structure in the least significant bytes, and place the padding in the high bits. Many thanks to Manjunath Matti for testing this patch on real hardware, and Drea Pinski for reviewing/approving it. The new test case may be a little fragile, but currently "works for me". Please feel free to tweak it for powerpc variants/environments I've not consider/encountered. 2026-05-08 Roger Sayle <[email protected]> gcc/ChangeLog PR middle-end/124637 * calls.cc (load_register_parameters): If using store_constructor to place a constant structure in a register, use a right shift to align the structure/padding if required on big-endian targets. gcc/testsuite/ChangeLog PR middle-end/124637 * gcc.target/powerpc/pr124637.c: New test case. (cherry picked from commit d28460bfcff89064d1a991f4532337b997d7e102)
