https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65342
--- Comment #11 from Iain Sandoe <iains at gcc dot gnu.org> --- Created attachment 35039 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35039&action=edit Patch for discussion OK so this is a frustrating area to debug. One can see the problem easily enough - but finding where it's introduced ... Question: Is there a reason that we don't have a constraint for DS-mode operands? Since there are so few constraint letters left, I have not attempted to add one - but curious about the reason. The patch is intended to do the following: 1. record that macho-pic indirections are always sufficiently aligned that a ds-mode offset is applicable (they reside in special sections with guaranteed alignment) - the picbase is also guaranteed to be aligned to 32b since it's a code label. - changes to config/darwin.{c,h} 2. I've added a new predicate (put it in darwin.md, for now since I'm just testing). - the predicate tries to look through the various cases to determine when a ds-mode operand is safe. 3. This is the bit that is in generic code and needs review: ISTM that the Y constraint code needs an additional check - at least for Darwin - if *only* for darwin, then I'm happy to conditionalise it on TARGET_MACHO. However, it's not obvious to me that no other target could be affected. What can happen is that the offset to the mem returns NULL_RTX (no offset) but there's actually quite a complex address expression - and that might not resolve to a sufficiently aligned object. Presently, the code just assumes that no offset means it's OK. --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -6378,11 +6378,20 @@ mem_operand_gpr (rtx op, machine_mode mode) { unsigned HOST_WIDE_INT offset; int extra; + unsigned align = MEM_ALIGN (op); rtx addr = XEXP (op, 0); - op = address_offset (addr); if (op == NULL_RTX) - return true; + { + /* No offset: + A naked reg is OK - any alignment works. */ + if (REG_P (addr)) + return true ; + /* Otherwise, we assume there will be a relocation, and we can't + guarantee it will fit unless the object referred to is sufficiently + aligned. */ + return align >= 32; + } NOTE: there are some debug changes in the patch - this is not intended for submission until point 3 is reviewed.