public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug regression/38674]  New: optimization bug.
@ 2008-12-30 16:14 gilles dot chanteperdrix at xenomai dot org
  2009-01-05 15:21 ` [Bug middle-end/38674] When storing in a register the address of a value contained in the same register, gcc 4.3.2 on ARM clobbers the register before saving its content on the stack gilles dot chanteperdrix at xenomai dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: gilles dot chanteperdrix at xenomai dot org @ 2008-12-30 16:14 UTC (permalink / raw)
  To: gcc-bugs

When compiling the following code with -O2:

#include <stdio.h>

static unsigned long long __attribute__((noinline)) f(void *ptr, unsigned long
long ull)
{
        register unsigned long __r2 __asm__ ("r2") = (unsigned long) (&ull);
        __asm__ __volatile__ ("" : "+r" (__r2));
        return * (unsigned long long *) __r2;
}

int main(void)
{
        fprintf(stderr, "f(NULL, 0): %Lu\n", f(NULL, 0));
        return 0;
}

we get the following warning:
/tmp/ccJNzMaH.s: Assembler messages:
/tmp/ccJNzMaH.s:21: Warning: source register same as write-back base

And when running the program on target, the printed return value of f is not 0.

A disassembly of f:
000083f4 <f>:
    83f4:       e24dd008        sub     sp, sp, #8      ; 0x8
    83f8:       e28d2008        add     r2, sp, #8      ; 0x8
    83fc:       e16220f8        strd    r2, [r2, #-8]!
    8400:       e8920003        ldm     r2, {r0, r1}
    8404:       e28dd008        add     sp, sp, #8      ; 0x8
    8408:       e12fff1e        bx      lr

shows that r2 seems to be clobbered before its value is saved on stack.


-- 
           Summary: optimization bug.
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: regression
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gilles dot chanteperdrix at xenomai dot org
GCC target triplet: armeb-unknown-linux-gnueabi


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


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <bug-38674-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2015-02-19 11:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-30 16:14 [Bug regression/38674] New: optimization bug gilles dot chanteperdrix at xenomai dot org
2009-01-05 15:21 ` [Bug middle-end/38674] When storing in a register the address of a value contained in the same register, gcc 4.3.2 on ARM clobbers the register before saving its content on the stack gilles dot chanteperdrix at xenomai dot org
2009-03-16 23:38 ` rearnsha at gcc dot gnu dot org
2009-03-16 23:39 ` rearnsha at gcc dot gnu dot org
     [not found] <bug-38674-4@http.gcc.gnu.org/bugzilla/>
2015-02-19 11:34 ` cbaylis at gcc dot gnu.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).