Compile the following code with -mthumb -O2 -Os,

extern void foo(int*, const char*, int);
void test(const char name[], int style)
{
   foo(0, name, style);
}

I got:

        push    {r4, lr}
        mov     r3, r0          //  A
        mov     r2, r1          //  B
        mov     r0, #0          //  C
        mov     r1, r3          //  D
        bl      foo
        pop     {r4, pc}

Instructions A and D move register r0 to r1, actually it can be replaced with 1
instruction
        mov  r1, r0
and place it between B and C.


-- 
           Summary: redundant register move with -mthumb
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carrot at google dot com
 GCC build triplet: i686-linux
  GCC host triplet: i686-linux
GCC target triplet: arm-eabi


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

Reply via email to