This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/40835] New: redundant comparison instruction


Compile the following code with options -Os -mthumb -march=armv5te

int bar();
void goo(int, int);
void foo()
{
  int v = bar();
  if (v == 0)
    return;
  goo(1, v);
}

Gcc generates:

        push    {r3, lr}
        bl      bar
        mov     r1, r0
        cmp     r0, #0    // *
        beq     .L1
        mov     r0, #1
        bl      goo
.L1:
        @ sp needed for prologue
        pop     {r3, pc}

The compare instruction is redundant since the previous move instruction has
already set the condition code according to the value of r0.


-- 
           Summary: redundant comparison instruction
           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=40835


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]