aboutsummaryrefslogtreecommitdiff
path: root/gcc/emit-rtl.cc
diff options
context:
space:
mode:
authorAlexandre Oliva <oliva@adacore.com>2023-05-24 03:07:56 -0300
committerAlexandre Oliva <oliva@gnu.org>2023-05-24 23:45:10 -0300
commitd6b756447cd58bcca20e6892790582308b869817 (patch)
tree6859139d78c62146977cb2d96a045cc6421dba7c /gcc/emit-rtl.cc
parent03a3736f9ed219bdb886ccf96e28307718f3ceba (diff)
downloadgcc-d6b756447cd58bcca20e6892790582308b869817.zip
gcc-d6b756447cd58bcca20e6892790582308b869817.tar.gz
gcc-d6b756447cd58bcca20e6892790582308b869817.tar.bz2
[PR100106] Reject unaligned subregs when strict alignment is required
The testcase for pr100106, compiled with optimization for 32-bit powerpc -mcpu=604 with -mstrict-align expands the initialization of a union from a float _Complex value into a load from an SCmode constant pool entry, aligned to 4 bytes, into a DImode pseudo, requiring 8-byte alignment. The patch that introduced the testcase modified simplify_subreg to avoid changing the MEM to outermode, but simplify_gen_subreg still creates a SUBREG or a MEM that would require stricter alignment than MEM's, and lra_constraints appears to get confused by that, repeatedly creating unsatisfiable reloads for the SUBREG until it exceeds the insn count. Avoiding the unaligned SUBREG, expand splits the DImode dest into SUBREGs and loads each SImode word of the constant pool with the proper alignment. for gcc/ChangeLog PR target/100106 * emit-rtl.cc (validate_subreg): Reject a SUBREG of a MEM that requires stricter alignment than MEM's. for gcc/testsuite/ChangeLog PR target/100106 * gcc.target/powerpc/pr100106-sa.c: New.
Diffstat (limited to 'gcc/emit-rtl.cc')
-rw-r--r--gcc/emit-rtl.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc
index 4036f4b..51db055 100644
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -987,6 +987,10 @@ validate_subreg (machine_mode omode, machine_mode imode,
return subreg_offset_representable_p (regno, imode, offset, omode);
}
+ /* Do not allow SUBREG with stricter alignment than the inner MEM. */
+ else if (reg && MEM_P (reg) && STRICT_ALIGNMENT
+ && MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (omode))
+ return false;
/* The outer size must be ordered wrt the register size, otherwise
we wouldn't know at compile time how many registers the outer