https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71680

--- Comment #9 from Alan Modra <amodra at gmail dot com> ---
lra doesn't load in SFmode due to the following condition in
lra-constraints.c:simplify_operand_subreg

  /* If we change address for paradoxical subreg of memory, the
     address might violate the necessary alignment or the access might
     be slow.  So take this into consideration.  We should not worry
     about access beyond allocated memory for paradoxical memory
     subregs as we don't substitute such equiv memory (see processing
     equivalences in function lra_constraints) and because for spilled
     pseudos we allocate stack memory enough for the biggest
     corresponding paradoxical subreg.  */
  if (MEM_P (reg)
      && (! SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (reg))
          || MEM_ALIGN (reg) >= GET_MODE_ALIGNMENT (mode)))

MEM_ALIGN here is 8 bits (from #pragma pack, and yes, the mem really is only
byte aligned), and rs6000.h does say that this access might be slow if in
SFmode.  It's true that an unaligned floating point storage access on power
might cause an alignment trap, so leaving aside the issue that mode only maps
loosely to register class, I think the rs6000.h definition of
SLOW_UNALIGNED_ACCESS is correct and lra is doing the right thing here.  Reload
is wrong to use a fp load (if mem align was always accurate, which it isn't).

Hmm, a change that doesn't cure this problem, but the condition might be better
as

  if (MEM_P (reg)
      && (! SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (reg))
          || SLOW_UNALIGNED_ACCESS (innermode, MEM_ALIGN (reg))
          || MEM_ALIGN (reg) >= GET_MODE_ALIGNMENT (mode)))

ie. if both innermode and mode are slow then lra may as well go ahead and use
the subreg mode.

Reply via email to