Patchwork Generate i486 code by default on FreeBSD/ia32

login
register
mail settings
Submitter Tijl Coosemans
Date Feb. 6, 2011, 2:07 p.m.
Message ID <201102061507.56052.tijl@coosemans.org>
Download mbox | patch
Permalink /patch/82055/
State New
Headers show

Comments

Tijl Coosemans - Feb. 6, 2011, 2:07 p.m.
When targeting FreeBSD/ia32 6.0 and newer, cc1 uses -march=i486
-mtune=generic by default, i.e. when not passed -march/-mtune on the
command line. These are correct defaults.

The gcc driver however always passes -march/-mtune to cc1 so that
default behaviour never kicks in. The driver's default values of
-march/-mtune are determined by ./configure (gcc/config.gcc).

The configure script derives them from the first field in the target
triplet (by default), e.g. i386-portbld-freebsd8.0 becomes -march=i386
-mtune=i386.

The problem now is that on FreeBSD the first field of the target tends
to mean an architecture rather than a specific cpu model. So i386 in
the example above is used to mean ia32 in general, not really the i386
cpu specifically. Deriving values for -march/-mtune from it is
therefore suboptimal.

There are basically two approaches to improve this. Either don't let
the configure script derive anything from the target at all, as done on
Darwin, or tell the configure script that i386-portbld-freebsd8.0 means
-march=i486.

The attached patch takes the latter approach. It has the advantage that
the behaviour is unchanged for targets like i686-portbld-freebsd8.0.

Test results by Gerald Pfeifer:
http://gcc.gnu.org/ml/gcc-testresults/2011-02/msg00216.html (before)
http://gcc.gnu.org/ml/gcc-testresults/2011-02/msg00273.html (after)

Tijl Coosemans

        * config.gcc (FreeBSD/i386): Default arch is i486.
Gerald Pfeifer - Feb. 8, 2011, 12:52 a.m.
On Sun, 6 Feb 2011, Tijl Coosemans wrote:
> When targeting FreeBSD/ia32 6.0 and newer, cc1 uses -march=i486
> -mtune=generic by default, i.e. when not passed -march/-mtune on the
> command line. These are correct defaults.
> 
> The gcc driver however always passes -march/-mtune to cc1 so that
> default behaviour never kicks in. The driver's default values of
> -march/-mtune are determined by ./configure (gcc/config.gcc).

We really should address this with GCC 4.6.  Right now, GCC on
FreeBSD x86 underperforms quite a bit due to this.

I'll be happy to commit this; who 's gonna bite and approve? ;-)


(Is this sufficiently aggressive, actually?  Could we not make this
i686 even, and include SSE2?  Perhaps on some newer versions of the
OS at least, Tijl?)

Gerald

>         * config.gcc (FreeBSD/i386): Default arch is i486.
> 
> --- gcc/config.gcc.orig	2011-01-26 05:19:58.000000000 +0100
> +++ gcc/config.gcc	2011-02-01 16:58:17.000000000 +0100
> @@ -2766,6 +2766,16 @@
>  arch_without_sse2=no
>  arch_without_64bit=no
>  case ${target} in
> +  i386-*-freebsd*)
> +    if test $fbsd_major -ge 6; then
> +      arch=i486
> +    else
> +      arch=i386
> +    fi
> +    cpu=generic
> +    arch_without_sse2=yes
> +    arch_without_64bit=yes
> +    ;;
>    i386-*-*)
>      arch=i386
>      cpu=i386
>
Tijl Coosemans - Feb. 8, 2011, 3:57 p.m.
On Tuesday 08 February 2011 01:52:21 Gerald Pfeifer wrote:
> On Sun, 6 Feb 2011, Tijl Coosemans wrote:
>> When targeting FreeBSD/ia32 6.0 and newer, cc1 uses -march=i486
>> -mtune=generic by default, i.e. when not passed -march/-mtune on the
>> command line. These are correct defaults.
>> 
>> The gcc driver however always passes -march/-mtune to cc1 so that
>> default behaviour never kicks in. The driver's default values of
>> -march/-mtune are determined by ./configure (gcc/config.gcc).
> 
> We really should address this with GCC 4.6.  Right now, GCC on
> FreeBSD x86 underperforms quite a bit due to this.
> 
> I'll be happy to commit this; who 's gonna bite and approve? ;-)
> 
> 
> (Is this sufficiently aggressive, actually?  Could we not make this
> i686 even, and include SSE2?  Perhaps on some newer versions of the
> OS at least, Tijl?)

No, only support for i386 has been removed. The i486 is still supported
so by default you cannot use MMX or SSE instructions.

The advantage of using i486 over i386 is that libstdc++ will use atomic
instructions in a number of places instead of a mutex and that some
support functions in C++ headers become inlinable.
Gerald Pfeifer - Feb. 22, 2011, 10:06 a.m.
Ping.

http://gcc.gnu.org/ml/gcc-patches/2011-02/msg00353.html

Gerald

On Tue, 8 Feb 2011, Gerald Pfeifer wrote:
>> When targeting FreeBSD/ia32 6.0 and newer, cc1 uses -march=i486
>> -mtune=generic by default, i.e. when not passed -march/-mtune on the
>> command line. These are correct defaults.
>> 
>> The gcc driver however always passes -march/-mtune to cc1 so that
>> default behaviour never kicks in. The driver's default values of
>> -march/-mtune are determined by ./configure (gcc/config.gcc).
> We really should address this with GCC 4.6.  Right now, GCC on
> FreeBSD x86 underperforms quite a bit due to this.
> 
> I'll be happy to commit this; who 's gonna bite and approve? ;-)
> 
>>         * config.gcc (FreeBSD/i386): Default arch is i486.
Paolo Bonzini - Feb. 22, 2011, 10:47 a.m.
On 02/06/2011 03:07 PM, Tijl Coosemans wrote:
> When targeting FreeBSD/ia32 6.0 and newer, cc1 uses -march=i486
> -mtune=generic by default, i.e. when not passed -march/-mtune on the
> command line. These are correct defaults.
>
> The gcc driver however always passes -march/-mtune to cc1 so that
> default behaviour never kicks in. The driver's default values of
> -march/-mtune are determined by ./configure (gcc/config.gcc).
>
> The configure script derives them from the first field in the target
> triplet (by default), e.g. i386-portbld-freebsd8.0 becomes -march=i386
> -mtune=i386.
>
> The problem now is that on FreeBSD the first field of the target tends
> to mean an architecture rather than a specific cpu model. So i386 in
> the example above is used to mean ia32 in general, not really the i386
> cpu specifically. Deriving values for -march/-mtune from it is
> therefore suboptimal.
>
> There are basically two approaches to improve this. Either don't let
> the configure script derive anything from the target at all, as done on
> Darwin, or tell the configure script that i386-portbld-freebsd8.0 means
> -march=i486.
>
> The attached patch takes the latter approach. It has the advantage that
> the behaviour is unchanged for targets like i686-portbld-freebsd8.0.
>
> Test results by Gerald Pfeifer:
> http://gcc.gnu.org/ml/gcc-testresults/2011-02/msg00216.html (before)
> http://gcc.gnu.org/ml/gcc-testresults/2011-02/msg00273.html (after)
>
> Tijl Coosemans
>
>          * config.gcc (FreeBSD/i386): Default arch is i486.
>
> --- gcc/config.gcc.orig	2011-01-26 05:19:58.000000000 +0100
> +++ gcc/config.gcc	2011-02-01 16:58:17.000000000 +0100
> @@ -2766,6 +2766,16 @@
>   arch_without_sse2=no
>   arch_without_64bit=no
>   case ${target} in
> +  i386-*-freebsd*)
> +    if test $fbsd_major -ge 6; then
> +      arch=i486
> +    else
> +      arch=i386
> +    fi
> +    cpu=generic
> +    arch_without_sse2=yes
> +    arch_without_64bit=yes
> +    ;;
>     i386-*-*)
>       arch=i386
>       cpu=i386
>

Ok.

Paolo

Patch

--- gcc/config.gcc.orig	2011-01-26 05:19:58.000000000 +0100
+++ gcc/config.gcc	2011-02-01 16:58:17.000000000 +0100
@@ -2766,6 +2766,16 @@ 
 arch_without_sse2=no
 arch_without_64bit=no
 case ${target} in
+  i386-*-freebsd*)
+    if test $fbsd_major -ge 6; then
+      arch=i486
+    else
+      arch=i386
+    fi
+    cpu=generic
+    arch_without_sse2=yes
+    arch_without_64bit=yes
+    ;;
   i386-*-*)
     arch=i386
     cpu=i386