This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug regression/39836] New: [4.4 regression] unoptimal code generated
- From: "alexvod at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Apr 2009 15:40:07 -0000
- Subject: [Bug regression/39836] New: [4.4 regression] unoptimal code generated
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Very simple code:
int* func();
int func2(long long);
void test (int unused, int idx, char tag, long long value)
{
int *p = func() + idx;
switch (tag) {
case 1:
*p = (int) value;
case 2:
*p = func2(value);
}
}
is compiled to 46 bytes by GCC 4.3.1 and to 48 bytes by GCC 4.4.0. Bisection
shows that it was changed by
http://gcc.gnu.org/viewcvs?view=rev&revision=139949:
Code generated by 139948:
test:
push {r3, r4, r5, r6, r7, lr}
mov r4, r1
mov r5, r2
ldr r6, [sp, #24]
ldr r7, [sp, #28]
bl func
lsl r4, r4, #2
add r4, r0, r4
cmp r5, #1
beq .L3
cmp r5, #2
bne .L5
b .L4
.L3:
str r6, [r4]
.L4:
mov r0, r6
mov r1, r7
bl func2
str r0, [r4]
.L5:
@ sp needed for prologue
pop {r3, r4, r5, r6, r7, pc}
Code generated by 139949:
test:
push {r4, r5, r6, r7, lr}
sub sp, sp, #12
mov r5, r1
ldr r1, [sp, #36]
mov r6, r2
ldr r7, [sp, #32]
str r1, [sp, #4]
bl func
lsl r4, r5, #2
add r4, r0, r4
ldr r1, [sp, #4]
cmp r6, #1
beq .L3
cmp r6, #2
bne .L5
b .L4
.L3:
str r7, [r4]
.L4:
mov r0, r7
bl func2
str r0, [r4]
.L5:
add sp, sp, #12
@ sp needed for prologue
pop {r4, r5, r6, r7, pc}
Temporary variable was spilled on the stack [sp+4].
BTW, this function is compiled by GCC 4.2.1 to 42 (which is event better!).
--
Summary: [4.4 regression] unoptimal code generated
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: regression
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alexvod at google dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: arm-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39836