This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Enable SSE math on i386 with -Ofast


On Fri, 4 Oct 2013, Jan Hubicka wrote:

> Hi,
> this patch makes -Ofast to also imply -mfpmath=sse.  It is important win on
> SPECfP (2000 and 2006). Even though for exmaple the following
> float a(float b)
> {
>    return b+10;
> }
> 
> results in somewhat ridiculous
> a:
> .LFB0:  
>         .cfi_startproc
>         subl    $4, %esp
>         .cfi_def_cfa_offset 8
>         movss   .LC0, %xmm0
>         addss   8(%esp), %xmm0
>         movss   %xmm0, (%esp)
>         flds    (%esp)
>         addl    $4, %esp
>         .cfi_def_cfa_offset 4
>         ret
> 
> I wonder if we can get rid at least of the redundant stack alignment on ESP...
> 
> Bootstrapped/regtested x86_64-linux, will commit it on weekend if there are no
> complains.  I wonder if -ffast-math should do the same - it is documented as enabling
> explicit set of options, bu that can be changed I guess.

I wonder if we can restrict -mfpmath=sse to local functions where we can
change the ABI ... (do we change the local functions ABI with 
-mfpmath=sse?)

Richard.

> 	* invoke.texi (Ofast): Update documentation.
> 	* i386.h (TARGET_FPMATH_DEFAULT): Enable SSE math with -Ofast.
> Index: doc/invoke.texi
> ===================================================================
> --- doc/invoke.texi     (revision 203161)
> +++ doc/invoke.texi     (working copy)
> @@ -6796,6 +6796,7 @@ Disregard strict standards compliance.
>  valid for all standard-compliant programs.
>  It turns on @option{-ffast-math} and the Fortran-specific
>  @option{-fno-protect-parens} and @option{-fstack-arrays}.
> +On i386 target it also enable @option{-mfpmath=sse}.
>  
>  @item -Og
>  @opindex Og
> Index: config/i386/i386.h
> ===================================================================
> --- config/i386/i386.h	(revision 203161)
> +++ config/i386/i386.h	(working copy)
> @@ -209,7 +209,8 @@ extern const struct processor_costs ix86
>  
>  #ifndef TARGET_FPMATH_DEFAULT
>  #define TARGET_FPMATH_DEFAULT \
> -  (TARGET_64BIT && TARGET_SSE ? FPMATH_SSE : FPMATH_387)
> +  ((TARGET_64BIT && TARGET_SSE) \
> +   || (TARGET_SSE && optimize_fast) ? FPMATH_SSE : FPMATH_387)
>  #endif
>  
>  #define TARGET_FLOAT_RETURNS_IN_80387 TARGET_FLOAT_RETURNS
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]