public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/56897] New: unaligned memory access on alpha
@ 2013-04-10  3:53 martynas at venck dot us
  2013-04-10  3:55 ` [Bug target/56897] " martynas at venck dot us
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: martynas at venck dot us @ 2013-04-10  3:53 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56897

             Bug #: 56897
           Summary: unaligned memory access on alpha
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: martynas@venck.us


Hi,

After looking at the RTL dumps here and there, I've noticed that
GCC generates unaligned loads in the following manner:

foo = ([reg:X & -8] << (64 - (((reg:FP+reg:Y) & 0x7) << 3))) >> 56

Obviously, we're losing every eighth byte here (consider FP-0,FP-8).
Since FP is aligned, GCC optimizes this to foo = 0.  The right way
to do this is:

foo = ([reg:X & -8] << (56 - (((reg:FP+reg:Y-1) & 0x7) << 3))) >> 56

To reproduce, try this out:

unsigned long foo = 0x010203040a0b0c0d;
printf("%02x",   *((char *)&foo + 7));

With -O (and onwards) it will turn out to be zero;  at every &X+15,
&X+23, etc.  Depending on the offset from the frame pointer.

Attached the diff against trunk.

Martynas.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-04-16 15:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10  3:53 [Bug target/56897] New: unaligned memory access on alpha martynas at venck dot us
2013-04-10  3:55 ` [Bug target/56897] " martynas at venck dot us
2013-04-10  6:43 ` ubizjak at gmail dot com
2013-04-15  7:54 ` ubizjak at gmail dot com
2013-04-16  4:11 ` martynas at venck dot us
2013-04-16  4:16 ` martynas at venck dot us
2013-04-16  4:18 ` martynas at venck dot us
2013-04-16 15:15 ` ubizjak at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).