Bug 6052 - suboptimal code
Summary: suboptimal code
Status: CLOSED WORKSFORME
Alias: None
Product: Sisyphus
Classification: Development
Component: gcc4.4 (show other bugs)
Version: unstable
Hardware: all Linux
: P2 normal
Assignee: Gleb F-Malinovskiy
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-07 13:07 MSK by Alexey Voinov
Modified: 2010-11-04 23:25 MSK (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Voinov 2005-02-07 13:07:21 MSK
$ cat > test.c
extern int g(int);
int f(int x) { return g(x); }

$ gcc -S -O3 test.c -o -
	.file	"test.c"
	.text
	.p2align 4,,15
.globl f
	.type	f, @function
f:
	pushl	%ebp
	movl	%esp, %ebp
	popl	%ebp
	jmp	g
	.size	f, .-f
	.section	.note.GNU-stack,"",@progbits
	.ident	"GCC: (GNU) 3.4.3 20050104 (ALT Linux, build 3.4.3-alt2)"

Obviously, pushl/movl/popl code does nothing and can be completely ommited.
Comment 1 Michael Shigorin 2006-05-13 18:24:18 MSD
look at 4.1?
Comment 2 Dmitry V. Levin 2006-05-27 03:02:41 MSD
Same with gcc-4.1.1; maybe I should report it upstream? :)
Comment 3 Kirill A. Shutemov 2010-11-04 23:25:37 MSK
It seems fixed in gcc4.5:

$ gcc -S -O3 test.c -o -
        .file   "test.c"
        .text
        .p2align 4,,15
.globl f
        .type   f, @function
f:
.LFB0:
        .cfi_startproc
        jmp     g
        .cfi_endproc
.LFE0:
        .size   f, .-f
        .ident  "GCC: (GNU) 4.5.1 20100924 (ALT Linux 4.5.1-alt1)"
        .section        .note.GNU-stack,"",@progbits