The following code: --------------------------------------------- extern void bar (double); void foo (void) { bar (0.0); } --------------------------------------------- used to produce a tail call with GCC 3.3.3 (SuSE Linux): --------------------------------------------- .text .p2align 4,,15 .globl foo .type foo, @function foo: .LFB3: xorpd %xmm0, %xmm0 jmp bar .LFE3: .size foo, .-foo --------------------------------------------- GCC 4.0 20050124 produces a real call instead: --------------------------------------------- .text .p2align 4,,15 .globl foo .type foo, @function foo: .LFB2: xorpd %xmm0, %xmm0 subq $8, %rsp .LCFI0: call bar addq $8, %rsp ret .LFE2: .size foo, .-foo --------------------------------------------- The problem appears to be in expanding from trees to RTL because the call is properly marked as being in a tail position: ;; Function foo (foo) Analyzing Edge Insertions. foo () { <bb 0>: bar (0.0) [tail call]; return; } This happens for less trivial functions also, and can be a pretty severe code pessimization.
-- Summary: [4.0 regression] missed tail call Product: gcc Version: 4.0.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P1 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: steven at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org,hubicka at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19616