public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: d.mueller@elsoft.ch
To: gcc-gnats@gcc.gnu.org
Subject: optimization/10241: X86 -> ARM cross-compiler emits unnecessary register move
Date: Thu, 27 Mar 2003 11:44:00 -0000	[thread overview]
Message-ID: <20030327113538.27033.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3127 bytes --]


>Number:         10241
>Category:       optimization
>Synopsis:       X86 -> ARM cross-compiler emits unnecessary register move
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 27 11:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     David Müller
>Release:        gcc version 3.2.2
>Organization:
>Environment:
> uname -a
Linux pcdm 2.4.20 #1 Fri Jan 24 07:26:39 CET 2003 i686 unknown
> /lib/libc.so.6
GNU C Library stable release version 2.2.5, by Roland McGrath et al.
Copyright (C) 1992-2001, 2002 Free Software Foundation, Inc.
> arm-linux-gcc -v
Reading specs from /opt/toolchains/lib/gcc-lib/arm-linux/3.2.2/specs
Configured with: ../gcc-3.2.2/configure -v --target=arm-linux --prefix=/opt/toolchains --enable-shared --disable-static --enable-languages=c,c++ --enable-threads
Thread model: posix
gcc version 3.2.2
>Description:
There is an unnecessary register move "mov r2, r1" emited at address 0xc . The base address still present in r1 could be used instead in the register load at address 0x10:


c3.o:     file format elf32-littlearm

Disassembly of section .text:

00000000 <Bar>:
#define T_BASE 0x12345678

static inline T * const GetBase_T(void)
{
        return (T * const)T_BASE;
   0:   e59f1020        ldr     r1, [pc, #32]   ; 28 <Bar+0x28>
}

static inline void Foo(void)
{
        T * const base = GetBase_T();

        while ((base->reg & 0x80) != 0);
}


int Bar(void)
{

        T * const base = GetBase_T();

        base->reg = 1;
   4:   e3a03001        mov     r3, #1  ; 0x1
   8:   e5813000        str     r3, [r1]
   c:   e1a02001        mov     r2, r1    <----- 
  10:   e5923000        ldr     r3, [r2]
  14:   e2130080        ands    r0, r3, #128    ; 0x80
  18:   03a03002        moveq   r3, #2  ; 0x2
  1c:   05813000        streq   r3, [r1]
        Foo();
        base->reg = 2;

        return 0;
}
  20:   01a0f00e        moveq   pc, lr
  24:   ea000002        b       10 <Bar+0x10>
  28:   12345678        eornes  r5, r4, #125829120      ; 0x7800000
>How-To-Repeat:
> arm-linux-gcc -Wall -O2 -g -c c3.i
> arm-linux-objdump -S c3.o
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="c3.i"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="c3.i"

IyAxICJjMy5jIgojIDEgIjxidWlsdC1pbj4iCiMgMSAiPGNvbW1hbmQgbGluZT4iCiMgMSAiYzMu
YyIKdHlwZWRlZiB1bnNpZ25lZCBsb25nIHUzMjsKCnR5cGVkZWYgdm9sYXRpbGUgdTMyIFRfUkVH
MzI7Cgp0eXBlZGVmIHN0cnVjdCB7CiAgICAgICAgVF9SRUczMiByZWc7Cn0gVDsKCgoKCnN0YXRp
YyBpbmxpbmUgVCAqIGNvbnN0IEdldEJhc2VfVCh2b2lkKQp7CiAgICAgICAgcmV0dXJuIChUICog
Y29uc3QpMHgxMjM0NTY3ODsKfQoKc3RhdGljIGlubGluZSB2b2lkIEZvbyh2b2lkKQp7CiAgICAg
ICAgVCAqIGNvbnN0IGJhc2UgPSBHZXRCYXNlX1QoKTsKCiAgICAgICAgd2hpbGUgKChiYXNlLT5y
ZWcgJiAweDgwKSAhPSAwKTsKfQoKaW50IEJhcih2b2lkKQp7CgogICAgICAgIFQgKiBjb25zdCBi
YXNlID0gR2V0QmFzZV9UKCk7CgogICAgICAgIGJhc2UtPnJlZyA9IDE7CiAgICAgICAgRm9vKCk7
CiAgICAgICAgYmFzZS0+cmVnID0gMjsKCiAgICAgICAgcmV0dXJuIDA7Cn0K


             reply	other threads:[~2003-03-27 11:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-27 11:44 d.mueller [this message]
2003-03-27 11:56 rearnsha

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=20030327113538.27033.qmail@sources.redhat.com \
    --to=d.mueller@elsoft.ch \
    --cc=gcc-gnats@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).