This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/24233] New: -fomit-frame-pointer causes really dire code to be generated
- From: "arjanv at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Oct 2005 10:38:22 -0000
- Subject: [Bug c/24233] New: -fomit-frame-pointer causes really dire code to be generated
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The testcase (taken from zlib) below
int huft_build(void)
{
unsigned int c[16];
unsigned int *p;
p = c;
#define C0 *p++ = 0;
#define C2 C0 C0 C0 C0
#define C4 C2 C2 C2 C2
C4
/* stop optimisation from throwing all the above code away */
__asm__ __volatile__("": : :"memory");
return *p;
}
yields really bad code on x86 when using the following compiler flags
gcc -O2 -fomit-frame-pointer -march=i686 -c inftrees.c -o inftrees.o
snippet from objdump output:
3: 31 c0 xor %eax,%eax
5: 89 44 24 04 mov %eax,0x4(%esp)
9: 31 c0 xor %eax,%eax
b: 31 c9 xor %ecx,%ecx
d: 89 44 24 08 mov %eax,0x8(%esp)
11: 31 c0 xor %eax,%eax
13: 31 d2 xor %edx,%edx
15: 89 44 24 0c mov %eax,0xc(%esp)
19: 31 c0 xor %eax,%eax
1b: 89 44 24 10 mov %eax,0x10(%esp)
1f: 31 c0 xor %eax,%eax
21: 89 44 24 1c mov %eax,0x1c(%esp)
25: 31 c0 xor %eax,%eax
27: 89 44 24 20 mov %eax,0x20(%esp)
2b: 31 c0 xor %eax,%eax
2d: 89 44 24 24 mov %eax,0x24(%esp)
31: 31 c0 xor %eax,%eax
33: 89 44 24 28 mov %eax,0x28(%esp)
37: 31 c0 xor %eax,%eax
notice how it zeroes %eax after each write, instead of remembering eax was
already zero!
without -fomit-framepointer sane code is generated:
6: c7 45 c0 00 00 00 00 movl $0x0,0xffffffc0(%ebp)
d: c7 45 c4 00 00 00 00 movl $0x0,0xffffffc4(%ebp)
14: c7 45 c8 00 00 00 00 movl $0x0,0xffffffc8(%ebp)
1b: c7 45 cc 00 00 00 00 movl $0x0,0xffffffcc(%ebp)
etc
--
Summary: -fomit-frame-pointer causes really dire code to be
generated
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: arjanv at redhat dot com
GCC host triplet: i686-gnu-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24233