Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Sep 1995 18:59:09 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        hackers@freebsd.org, jehamby@lightside.com
Subject:   Re: -m486 option to GCC
Message-ID:  <199509080859.SAA07511@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>I remember in my Linux days that the '-m486' option was often passed to 
>GCC to provide optimizations for 486-class PC's.  Apparently it didn't 
>generate 486-specific code but simply padded functions out in such a way 
>that performance was improved on 486's without sacrificing compatibility 

It causes slightly different instructions to be chosen.  The effect is
very small.  The improvement for correct alignment is larger.  However,
the linux linker didn't support correct alignment (at least the a.out
version up to a year ago).  It aligns module text sections on 4 byte
boundaries, so the padding helped 1/4 of the time and harmed 3/4 of the
time.  The FreeBSD linker aligns module text sections on 16 byte
boundaries although this is a bit wasteful if -m486 wasn't used.
gcc-2.7.0 has some new -m flags that allow finer control over the
alignment.  E.g., you can use -m486 to get i486 instruction selection
and following it by some new alignment flags to get i386 aligment.  This
combination is said to be best for Pentiums.

>My question is:  In Linux, 'uname -m' will tell you 'i486' if you have a 
>486 or 'i386' otherwise (I'm not sure about Pentiums), whereas under 
>FreeBSD, it always returns 'i386'.  Therefore GCC by default is built NOT 
>to include the '-m486' option by default.  I would recommend that either:

`sysctl hw.model' gives the cpu model under FreeBSD.  Doesn't gcc's config
know about sysctl? :-)

>a) The kernel be changed to return the "proper" machine name, and GCC be
>recompiled with 486 optimizations on by default (since it doesn't hurt 
>performance on 386's).  Of course purists would argue that 'i386' is the 

It does hurt it - it gives worse instruction selection and wasteful
padding (which depletes the cache, and in the worst case when the padding
is executed to avoid a jump, up to 15 nop's are executed, taking 30
cycles to avoid a jump which would take only 9 cycles).

>generic architecture name and shouldn't change depending on which machine 
>you run 'uname' on.

I don't want to supported it because it is a lot of work for an average
performance gain of 0.1%-1% in favourable cases.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199509080859.SAA07511>