This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/40835] New: redundant comparison instruction
- From: "carrot at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2009 08:37:51 -0000
- Subject: [Bug target/40835] New: redundant comparison instruction
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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