public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikpe at it dot uu dot se" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/40668] 64-bit sparc miscompiles memcpy of argument inside switch
Date: Tue, 07 Jul 2009 11:36:00 -0000	[thread overview]
Message-ID: <20090707113552.32226.qmail@sourceware.org> (raw)
In-Reply-To: <bug-40668-16771@http.gcc.gnu.org/bugzilla/>



------- Comment #3 from mikpe at it dot uu dot se  2009-07-07 11:35 -------
Confirmed, with gcc-4.3-20090705 it works, with gcc-4.4-20090630 it fails.
Compiling with -S and comparing the .s files it looks like 4.4 completely
mis-schedules the code for put_uint32:

put_uint32:
        .register       %g2, #scratch
        .register       %g3, #scratch
        ldub    [%sp+2175], %g1
        ldub    [%sp+2176], %g3
        ldub    [%sp+2177], %g2
        ldub    [%sp+2178], %g4
        st      %o0, [%sp+2175]
        stb     %g4, [%o1+3]
        stb     %g1, [%o1]
        stb     %g3, [%o1+1]
        jmp     %o7+8
         stb    %g2, [%o1+2]

Notice how the store of %o0 to the four bytes at %sp+2175 comes after the
corresponding byte loads, so %g1 to %g4 are loaded with garbage, likely zeroes.

In contrast, gcc-4.3 generates the store before the loads:

put_uint32:
        .register       %g2, #scratch
        .register       %g3, #scratch
        st      %o0, [%sp+2175]
        ldub    [%sp+2176], %g3
        ldub    [%sp+2177], %g4
        ldub    [%sp+2178], %g2
        ldub    [%sp+2175], %g1
        stb     %g2, [%o1+3]
        stb     %g1, [%o1]
        stb     %g3, [%o1+1]
        jmp     %o7+8
         stb    %g4, [%o1+2]


-- 

mikpe at it dot uu dot se changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu dot se


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


  parent reply	other threads:[~2009-07-07 11:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07  5:56 [Bug target/40668] New: " blp at cs dot stanford dot edu
2009-07-07  5:58 ` [Bug target/40668] " blp at cs dot stanford dot edu
2009-07-07  5:58 ` blp at cs dot stanford dot edu
2009-07-07 11:36 ` mikpe at it dot uu dot se [this message]
2009-07-07 16:28 ` mikpe at it dot uu dot se
2009-07-07 19:05 ` jakub at gcc dot gnu dot org
2009-07-07 23:10 ` mikpe at it dot uu dot se
2009-07-08 16:43 ` mikpe at it dot uu dot se
2009-07-08 17:30 ` blp at cs dot stanford dot edu
2009-07-11  9:24 ` jakub at gcc dot gnu dot org
2009-07-11  9:26 ` jakub at gcc dot gnu dot org
2010-09-20 21:46 ` ebotcazou at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090707113552.32226.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).