This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/39989] New: [optimization]
- From: "carrot at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 May 2009 06:07:29 -0000
- Subject: [Bug c/39989] New: [optimization]
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compiling this code snippet with gcc for arm,
typedef struct node node_t;
typedef struct node *node_p;
struct node
{
int orientation;
node_p pred;
long depth;
};
node_t *primal_iminus(long *delta, node_t *iplus, node_t*jplus)
{
node_t *iminus = 0;
if( iplus->depth < jplus->depth )
{
if( iplus->orientation )
iminus = iplus;
iplus = iplus->pred;
}
return iminus;
}
I got:
.save {lr}
push {lr}
.LCFI0:
.LVL0:
.loc 1 13 0
ldr r0, [r1, #8]
.LVL1:
ldr r3, [r2, #8]
cmp r0, r3
bge .L2
.loc 1 15 0
ldr r2, [r1]
.LVL2:
cmp r2, #0
beq .L2
mov r0, r1
.LVL3:
b .L3
.LVL4:
.L2:
mov r0, #0
.LVL5:
.L3:
.LVL6:
.loc 1 20 0
@ sp needed for prologue
pop {pc}
In which lr is still live at the exit of the function, we can simply use BX
lr to return and avoid the prolog instruction push {lr}.
The options I used is:
-fno-exceptions -Wno-multichar -march=armv5te -mtune=xscale -msoft-float -fpic
-mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector
-fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__
-D__ARM_ARCH_5TE__ -fmessage-length=0 -W -Wall -Wno-unused -DSK_RELEASE
-DNDEBUG -g -Wstrict-aliasing=2 -fgcse-after-reload -frerun-cse-after-loop
-frename-registers -DNDEBUG -UDEBUG -MD -O2 -Os -mthumb -fomit-frame-pointer
-fno-strict-aliasing -finline-limit=64 -finline-functions
-fno-inline-functions-called-once
--
Summary: [optimization]
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
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=39989