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