This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/78355] LRA generates unaligned accesses when SLOW_UNALIGNED_ACCESS is 1


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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-11-15
                 CC|                            |ebotcazou at gcc dot gnu.org,
                   |                            |vmakarov at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> I think the problem here is that SLOW_UNALIGNED_ACCESS is sloppily
> defined by my port, and defaults.h, to be a constant, but it is then
> used with naturally-aligned data, access to which is never slow, and
> expected to return false. So it would probably be best to replace the
> condition by
> 
> 	  if (!SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (reg))
> 	      || (MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (innermode)
>                   && SLOW_UNALIGNED_ACCESS (innermode, MEM_ALIGN (reg)))
> 	      || MEM_ALIGN (reg) >= GET_MODE_ALIGNMENT (mode))
> 	    return true;

Yes, SLOW_UNALIGNED_ACCESS ought to be invoked only for unaligned accesses,
i.e. only when ALIGNMENT < GET_MODE_ALIGNMENT (mode), see e.g. the RTL
expander, so your proposed change is the way to go.  But I'd rewrite it into:

          if (!(MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (mode)
                && SLOW_UNALIGNED_ACCESS (mode, MEM_ALIGN (reg)))
              || (MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (innermode)
                  && SLOW_UNALIGNED_ACCESS (innermode, MEM_ALIGN (reg))))
            return true;

I'm going to test it on ARM, which has the same settings as your port, and this
will probably also help the SPARC port for the switch to LRA.

Vladimir, what do you think?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]