public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "akos dot pasztory at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/45094]  New: [arm] wrong instructions for dword move in some cases
Date: Tue, 27 Jul 2010 11:34:00 -0000	[thread overview]
Message-ID: <bug-45094-19487@http.gcc.gnu.org/bugzilla/> (raw)

gcc 4.5.0

$ cat /tmp/bug.c
extern int printf(const char *fmt, ...);
void foo(void *x) { printf("%p\n", x); }
void bar(long long *x) { printf("%lld ", *x); foo(x); }

int main()
{
        bar(&(long long){0ll});
        bar(&(long long){1ll});
        bar(&(long long){2ll});
        bar(&(long long){3ll});
        bar(&(long long){4ll});
        bar(&(long long){5ll});
        bar(&(long long){6ll});
        bar(&(long long){7ll});
        bar(&(long long){8ll});
        bar(&(long long){9ll});
        bar(&(long long){10ll});
        bar(&(long long){11ll});
        bar(&(long long){12ll});
        bar(&(long long){13ll});
        bar(&(long long){14ll});
        bar(&(long long){15ll});
        bar(&(long long){16ll});
        bar(&(long long){17ll});
        bar(&(long long){18ll});
        bar(&(long long){19ll});
        bar(&(long long){20ll});
        bar(&(long long){21ll});
        bar(&(long long){22ll});
        bar(&(long long){23ll});
        bar(&(long long){24ll});
        bar(&(long long){25ll});
        bar(&(long long){26ll});
        bar(&(long long){27ll});
        bar(&(long long){28ll});
        bar(&(long long){29ll});
        bar(&(long long){30ll});
        bar(&(long long){31ll});
        bar(&(long long){32ll});
        bar(&(long long){33ll});
        bar(&(long long){34ll});
        bar(&(long long){35ll});
        bar(&(long long){36ll});
        bar(&(long long){37ll});
        bar(&(long long){38ll});
        bar(&(long long){39ll});
        bar(&(long long){40ll});
        bar(&(long long){41ll});
        bar(&(long long){42ll});
        bar(&(long long){43ll});
        bar(&(long long){44ll});
        return 0;
}

$ cc -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -S -O2 /tmp/bug.c

inspect bug.s.  for a while gcc emits correct instructions:

...
        mov     r2, #29
        mov     r3, #0
        strd    r2, [r0, #-240]!
        bl      bar
        add     r0, sp, #360
        mov     r2, #30
        mov     r3, #0
        strd    r2, [r0, #-248]!
        bl      bar

however when reaching offset -256, it emits LDRs instead of STRs:

        add     r0, sp, #360
        mov     r2, #31
        mov     r3, #0
        ldr     r2, [r0, #-256]!
        ldr     r3, [r0, #4]
        bl      bar

the issue seems to be a typo in gcc/config/arm/arm.c:output_move_double()
introduced by commit [1].  i've tried to fix by applying the following:

--- ../gcc-4.5.0/gcc/config/arm/arm.c.orig      2010-07-27 14:22:42.000000000
+0300
+++ ../gcc-4.5.0/gcc/config/arm/arm.c   2010-07-27 14:23:05.000000000 +0300
@@ -12182,13 +12182,13 @@ output_move_double (rtx *operands)
            {
              if (GET_CODE (XEXP (operands[0], 0)) == PRE_MODIFY)
                {
-                 output_asm_insn ("ldr%?\t%0, [%1, %2]!", otherops);
-                 output_asm_insn ("ldr%?\t%H0, [%1, #4]", otherops);
+                 output_asm_insn ("str%?\t%0, [%1, %2]!", otherops);
+                 output_asm_insn ("str%?\t%H0, [%1, #4]", otherops);
                }
              else
                {
-                 output_asm_insn ("ldr%?\t%H0, [%1, #4]", otherops);
-                 output_asm_insn ("ldr%?\t%0, [%1], %2", otherops);
+                 output_asm_insn ("str%?\t%H0, [%1, #4]", otherops);
+                 output_asm_insn ("str%?\t%0, [%1], %2", otherops);
                }
            }
          else if (GET_CODE (XEXP (operands[0], 0)) == PRE_MODIFY)

[1]
http://repo.or.cz/w/official-gcc.git/commitdiff/f1225f6f0f9b7acb3a64314f2113807ebeea5abf?hp=78f46d4510475cdb9532b10787e82b476c9eeef1


-- 
           Summary: [arm] wrong instructions for dword move in some cases
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: akos dot pasztory at gmail dot com
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: arm-linux-gnueabi


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


             reply	other threads:[~2010-07-27 11:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-27 11:34 akos dot pasztory at gmail dot com [this message]
2010-07-27 12:48 ` [Bug target/45094] " ramana at gcc dot gnu dot org
2010-07-27 20:07 ` siarhei dot siamashka at gmail dot com
2010-08-01  8:44 ` qiyao at gcc dot gnu dot org
2010-08-01 11:18 ` akos dot pasztory at gmail dot com
2010-08-02  0:39 ` qiyao at gcc dot gnu dot org
2010-08-18 12:34 ` qiyao at gcc dot gnu dot org
2010-08-27 12:14 ` ramana 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=bug-45094-19487@http.gcc.gnu.org/bugzilla/ \
    --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).