Testcase:
void noop(char* foo) {}
For 64-bit it does the right thing:
$ gcc -O2 foo.c -S
Output is:
noop:
.LFB2:
rep
ret
However for 32-bit it has useless extra instructions:
$ gcc -m32 -O2 foo.c -S
noop:
pushl %ebp
movl %esp, %ebp
popl %ebp
ret
The push/mov/pop should be removed.
I tested this with gcc-4.2, 4.3, and 4.4(trunk revision 143382), all produce
same code.
--
Summary: missed optimization with -m32: empty functions shouldn't
contain push/mov/pop
Product: gcc
Version: 4.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: edwintorok at gmail dot com
GCC build triplet: x86_64-linux-gnu
GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38854