https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120722
--- Comment #3 from Andrew Stubbs <ams at gcc dot gnu.org> ---
It looks like this is the hunk that changes the behaviour.
--- a/gcc/emit-rtl.cc
+++ b/gcc/emit-rtl.cc
@@ -975,8 +975,9 @@ validate_subreg (machine_mode omode, machine_mode imode,
/* Verify that the offset is representable. */
- /* For hard registers, we already have most of these rules collected in
- subreg_offset_representable_p. */
+ /* Ensure that subregs of hard registers can be folded. In other words,
+ the hardware register must be valid in the subreg's outer mode,
+ and consequently the subreg can be replaced with a hardware register. */
if (reg && REG_P (reg) && HARD_REGISTER_P (reg))
{
unsigned int regno = REGNO (reg);
@@ -987,7 +988,9 @@ validate_subreg (machine_mode omode, machine_mode imode,
else if (!REG_CAN_CHANGE_MODE_P (regno, imode, omode))
return false;
- return subreg_offset_representable_p (regno, imode, offset, omode);
+ /* Pass true to allow_stack_regs because targets like x86
+ expect to be able to take subregs of the stack pointer. */
+ return simplify_subreg_regno (regno, imode, offset, omode, true) >= 0;
}
/* Do not allow normal SUBREG with stricter alignment than the inner MEM.
The actual code that rejects the pattern is this (unchanged in the patch):
/* See whether (reg:YMODE YREGNO) is valid.
??? We allow invalid registers if (reg:XMODE XREGNO) is also invalid.
This is a kludge to work around how complex FP arguments are passed
on IA-64 and should be fixed. See PR target/49226. */
if (!targetm.hard_regno_mode_ok (yregno, ymode)
&& targetm.hard_regno_mode_ok (xregno, xmode))
return -1;
The problem is that GCN vcc_lo is an SImode hardreg, so DImode also uses
vcc_hi, but vcc_hi is not allowed to be used as a register on its own, because
the compiler did all sorts of buggy nonsense if it was allowed. We achieved
this, years ago, by saying SImode is disallowed (even though it would
technically work), but there's an assumption here that the upper part of a
DImode register pair must allow SImode. Until now it was fine because it could
still be expressed as a subreg when necessary.