public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/43471]  New: Unnecessary reload of asm "m" operand address
@ 2010-03-21 20:08 mirq-gccboogs at rere dot qmqm dot pl
  2010-03-22 23:05 ` [Bug rtl-optimization/43471] " ramana at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: mirq-gccboogs at rere dot qmqm dot pl @ 2010-03-21 20:08 UTC (permalink / raw)
  To: gcc-bugs

code:

register int *p asm("r4");
void a()
{
        asm volatile("" : "+m" (*p));
}

generates:

[...]
        mov     r3, r4
[...]

when it should generate no move as the address register won't be modified
inside asm().

Similar bugs: #40680, #34283, #13355.

(gcc 4.5 from svn 157582)


-- 
           Summary: Unnecessary reload of asm "m" operand address
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mirq-gccboogs at rere dot qmqm dot pl
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-none-eabi


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


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

* [Bug rtl-optimization/43471] Unnecessary reload of asm "m" operand address
  2010-03-21 20:08 [Bug rtl-optimization/43471] New: Unnecessary reload of asm "m" operand address mirq-gccboogs at rere dot qmqm dot pl
@ 2010-03-22 23:05 ` ramana at gcc dot gnu dot org
  2010-03-23  5:43 ` mirq-gccboogs at rere dot qmqm dot pl
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ramana at gcc dot gnu dot org @ 2010-03-22 23:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ramana at gcc dot gnu dot org  2010-03-22 23:04 -------
Are you using any optimization at all ? 

With -O2 I see just a bx lr for Thumb2, Thumb1 and ARM.

a:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        bx      lr


What flags are you using ? 


-- 

ramana at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug rtl-optimization/43471] Unnecessary reload of asm "m" operand address
  2010-03-21 20:08 [Bug rtl-optimization/43471] New: Unnecessary reload of asm "m" operand address mirq-gccboogs at rere dot qmqm dot pl
  2010-03-22 23:05 ` [Bug rtl-optimization/43471] " ramana at gcc dot gnu dot org
@ 2010-03-23  5:43 ` mirq-gccboogs at rere dot qmqm dot pl
  2010-03-23  5:52 ` mirq-gccboogs at rere dot qmqm dot pl
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mirq-gccboogs at rere dot qmqm dot pl @ 2010-03-23  5:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from mirq-gccboogs at rere dot qmqm dot pl  2010-03-23 05:43 -------
Hmm. I must have missed something while cutting down the test case as this
simple example works now...

Here is bigger test that might be related:

code:

struct a {
        int f1, f2;
};

struct b {
        unsigned f3;
        struct a s1, s2;
};

register struct b *const reg asm("r4");

static int diff(struct a *ptr)
{
        return ptr->f1 > ptr->f2 ? ptr->f1 - ptr->f2 : 100 - ptr->f1;
}

void c(void);

void d(void)
{
        while (diff(&reg->s2))
                c();
}

compiles to:

d:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        push    {r5, lr}
        mov     r5, r4
        b       .L2
.L5:   
        bl      c
.L2:   
        ldr     r3, [r5, #12]
        ldr     r1, [r5, #16]
        rsb     r2, r3, #100
        cmp     r3, r1
        it      gt
        subgt   r2, r3, r1
        cmp     r2, #0
        bne     .L5
        pop     {r5, pc}

with:

arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -O3 -S a.c


-- 


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


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

* [Bug rtl-optimization/43471] Unnecessary reload of asm "m" operand address
  2010-03-21 20:08 [Bug rtl-optimization/43471] New: Unnecessary reload of asm "m" operand address mirq-gccboogs at rere dot qmqm dot pl
  2010-03-22 23:05 ` [Bug rtl-optimization/43471] " ramana at gcc dot gnu dot org
  2010-03-23  5:43 ` mirq-gccboogs at rere dot qmqm dot pl
@ 2010-03-23  5:52 ` mirq-gccboogs at rere dot qmqm dot pl
  2010-03-23 13:18 ` rearnsha at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mirq-gccboogs at rere dot qmqm dot pl @ 2010-03-23  5:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from mirq-gccboogs at rere dot qmqm dot pl  2010-03-23 05:52 -------
I checked some more variants of the simple asm() example - looks like I mixed
up compiler output files when preparing that one.


-- 


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


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

* [Bug rtl-optimization/43471] Unnecessary reload of asm "m" operand address
  2010-03-21 20:08 [Bug rtl-optimization/43471] New: Unnecessary reload of asm "m" operand address mirq-gccboogs at rere dot qmqm dot pl
                   ` (2 preceding siblings ...)
  2010-03-23  5:52 ` mirq-gccboogs at rere dot qmqm dot pl
@ 2010-03-23 13:18 ` rearnsha at gcc dot gnu dot org
  2010-03-23 14:04 ` mirq-gccboogs at rere dot qmqm dot pl
  2010-04-15 21:51 ` kkojima at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2010-03-23 13:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rearnsha at gcc dot gnu dot org  2010-03-23 13:18 -------
This second example clearly has nothing to do with the stated bug report
summary line (there's no "m" constraint anywhere in the test case), and you
make no attempt to explain what you think is wrong.  Please see the pages on
reporting bugs and make sure you provide sufficient details for a developer to
both *understand* and *replicate* the problem you are having.


-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug rtl-optimization/43471] Unnecessary reload of asm "m" operand address
  2010-03-21 20:08 [Bug rtl-optimization/43471] New: Unnecessary reload of asm "m" operand address mirq-gccboogs at rere dot qmqm dot pl
                   ` (3 preceding siblings ...)
  2010-03-23 13:18 ` rearnsha at gcc dot gnu dot org
@ 2010-03-23 14:04 ` mirq-gccboogs at rere dot qmqm dot pl
  2010-04-15 21:51 ` kkojima at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: mirq-gccboogs at rere dot qmqm dot pl @ 2010-03-23 14:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from mirq-gccboogs at rere dot qmqm dot pl  2010-03-23 14:04 -------
The problem is that gcc sometimes emits instructions that are copying the
global r4 (even when it's marked as const) into temporary. Originally I thought
that the simplies case was this asm statememt, but it looks like it depends on
having adress of a structure field taken as a parameter for a function that's
later inlined. I'll file a new report with the second example and this
explanation.


-- 


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


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

* [Bug rtl-optimization/43471] Unnecessary reload of asm "m" operand address
  2010-03-21 20:08 [Bug rtl-optimization/43471] New: Unnecessary reload of asm "m" operand address mirq-gccboogs at rere dot qmqm dot pl
                   ` (4 preceding siblings ...)
  2010-03-23 14:04 ` mirq-gccboogs at rere dot qmqm dot pl
@ 2010-04-15 21:51 ` kkojima at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: kkojima at gcc dot gnu dot org @ 2010-04-15 21:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from kkojima at gcc dot gnu dot org  2010-04-15 21:51 -------
Subject: Bug 43471

Author: kkojima
Date: Thu Apr 15 21:51:14 2010
New Revision: 158393

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158393
Log:
        PR target/43471
        * config/sh/sh.c (sh_legitimize_reload_address): Use
        MAYBE_BASE_REGISTER_RTX_P instead of BASE_REGISTER_RTX_P.
        Remove a unneeded check for offset_base.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/sh/sh.c


-- 


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


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

end of thread, other threads:[~2010-04-15 21:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-21 20:08 [Bug rtl-optimization/43471] New: Unnecessary reload of asm "m" operand address mirq-gccboogs at rere dot qmqm dot pl
2010-03-22 23:05 ` [Bug rtl-optimization/43471] " ramana at gcc dot gnu dot org
2010-03-23  5:43 ` mirq-gccboogs at rere dot qmqm dot pl
2010-03-23  5:52 ` mirq-gccboogs at rere dot qmqm dot pl
2010-03-23 13:18 ` rearnsha at gcc dot gnu dot org
2010-03-23 14:04 ` mirq-gccboogs at rere dot qmqm dot pl
2010-04-15 21:51 ` kkojima at gcc dot gnu dot org

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).