http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47253
Summary: Conditional jump to tail function is not generated
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
I hope the summary is descriptive enough.
Take the following code:
----- testcase.c -----
void bar(void);
void foo(int c)
{
if (c) bar();
}
----------------------
With -O3, gcc generated this code:
foo:
.LFB0:
.cfi_startproc
test edi, edi # c
jne .L4 #,
rep
ret
.p2align 4,,10
.p2align 3
.L4:
jmp bar #
.cfi_endproc
and with -Os:
foo:
.LFB0:
.cfi_startproc
test edi, edi # c
je .L1 #,
jmp bar #
.L1:
ret
.cfi_endproc
while better would be:
foo:
test edi, edi
jne .L1
rep # only without -Os
ret
I tested 3.3.6, 3.4.6, 4.4.5, 4.6.0, neither generates the "better" code.