This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Enable SSE math on i386 with -Ofast
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: Richard Biener <rguenther at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 9 Oct 2013 01:39:46 +0200
- Subject: Re: Enable SSE math on i386 with -Ofast
- Authentication-results: sourceware.org; auth=none
- References: <20131004105656 dot GA25297 at kam dot mff dot cuni dot cz> <alpine dot LNX dot 2 dot 00 dot 1310071049170 dot 5759 at zhemvz dot fhfr dot qr> <20131007092243 dot GA358 at kam dot mff dot cuni dot cz> <alpine dot LNX dot 2 dot 00 dot 1310071124520 dot 5759 at zhemvz dot fhfr dot qr> <20131007093238 dot GB358 at kam dot mff dot cuni dot cz>
Hi,
this is patch I ended up comitting after some furhter testing. The difference to initial
version is that it now eanbles SSE math with -ffast-math too and it does so outside the
ugly target macro.
Bootstrapped/regtested x86_64-linux, tested with -m32
Honza
* config/i386/i386.c (ix86_option_override_internal): Switch
to SSE math for -ffast-math when target ISA supports SSE2.
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 203252)
+++ config/i386/i386.c (working copy)
@@ -3769,6 +3769,19 @@ ix86_option_override_internal (bool main
}
}
}
+ /* For all chips supporting SSE2, -mfpmath=sse performs better than
+ fpmath=387. The second is however default at many targets since the
+ extra 80bit precision of temporaries is considered to be part of ABI.
+ Overwrite the default at least for -ffast-math.
+ TODO: -mfpmath=both seems to produce same performing code with bit
+ smaller binaries. It is however not clear if register allocation is
+ ready for this setting.
+ Also -mfpmath=387 is overall a lot more compact (bout 4-5%) than SSE
+ codegen. We may switch to 387 with -ffast-math for size optimized
+ functions. */
+ else if (fast_math_flags_set_p (&global_options)
+ && TARGET_SSE2)
+ ix86_fpmath = FPMATH_SSE;
else
ix86_fpmath = TARGET_FPMATH_DEFAULT;