Bug 6052 - suboptimal code
: suboptimal code
Status: CLOSED WORKSFORME
: Sisyphus
(All bugs in Sisyphus/gcc4.4)
: unstable
: all Linux
: P2 normal
Assigned To:
:
:
:
:
:
  Show dependency tree
 
Reported: 2005-02-07 13:07 by
Modified: 2010-11-04 23:25 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2005-02-07 13:07:21
$ 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 From 2006-05-13 18:24:18 -------
look at 4.1?
------- Comment #2 From 2006-05-27 03:02:41 -------
Same with gcc-4.1.1; maybe I should report it upstream? :)
------- Comment #3 From 2010-11-04 23:25:37 -------
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