This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
x86 linux oddity
- To: egcs at cygnus dot com, scox at cygnus dot com
- Subject: x86 linux oddity
- From: Michael Meissner <meissner at cygnus dot com>
- Date: Wed, 29 Oct 1997 16:31:26 -0500
I was answering a question about optimization and noticed the
following oddity on the x86 egcs linux port. Consider the following
program:
int a, b, c, d, e, f, g, x, y;
main(){
x=(b+c+d)*(e/f+g);
y=(b+c+d)/(e/f+g);
return 0;
}
The current egcs linux port generates the following code using the
-fomit-frame-pointer -O2 switches on my pentium pro. Note that it
stores and restores ebx, even though ebx is never used.
.file "foo.c"
.version "01.01"
/ GNU C version egcs-2.90.14 971023 (gcc2-970802 experimental) (i686-pc-linux-gnulibc1) compiled by GNU C version 2.7.2.1.
/ options passed: -O2 -fomit-frame-pointer
/ options enabled: -fdefer-pop -fomit-frame-pointer -fcse-follow-jumps
/ -fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
/ -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse -finline
/ -fkeep-static-consts -fcaller-saves -fpcc-struct-return
/ -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns2 -fcommon
/ -fverbose-asm -fgnu-linker -fregmove -falias-check -fargument-alias
/ -m80387 -mhard-float -mno-soft-float -mieee-fp -mfp-ret-in-387
/ -mschedule-prologue -mcpu=pentiumpro -march=pentium
gcc2_compiled.:
.text
.align 4
.globl main
.type main,@function
main:
pushl %esi
movl e,%esi
movl %esi,%eax
cltd
idivl f
movl c,%ecx
addl b,%ecx
addl d,%ecx
movl %eax,%esi
addl g,%esi
movl %ecx,%eax
imull %esi,%eax
movl %eax,x
movl %ecx,%eax
cltd
idivl %esi
movl %eax,%ecx
movl %ecx,y
pushl %ebx <----- useless
xorl %eax,%eax
popl %ebx <----- useless
popl %esi
ret
.Lfe1:
.size main,.Lfe1-main
.comm a,4,4
.comm b,4,4
.comm c,4,4
.comm d,4,4
.comm e,4,4
.comm f,4,4
.comm g,4,4
.comm x,4,4
.comm y,4,4
.ident "GCC: (GNU) egcs-2.90.14 971023 (gcc2-970802 experimental)"
--
Michael Meissner, Cygnus Solutions (Massachusetts office)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com, 617-354-5416 (office), 617-354-7161 (fax)