diff mbox series

i386: Require SSE for SSE FP math

Message ID 20190220143527.GA20239@gmail.com
State New
Headers show
Series i386: Require SSE for SSE FP math | expand

Commit Message

H.J. Lu Feb. 20, 2019, 2:35 p.m. UTC
On Wed, Feb 20, 2019 at 08:12:35AM +0100, Uros Bizjak wrote:
> On Tue, Feb 19, 2019 at 9:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Tue, Feb 19, 2019 at 6:16 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> > >
> > > On Tue, Feb 19, 2019 at 2:49 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > >
> > > > ix86_fpmath should be set to combination of FPMATH_387 and FPMATH_SSE.
> > > > When SSE is disabled, it should be set to FPMATH_387 and 387 codegen is
> > > > also controlled by -msoft-float.
> > > >
> > > > gcc/
> > > >
> > > >         PR target/89397
> > > >         * config/i386/i386.c (ix86_option_override_internal): Set
> > > >         opts->x_ix86_fpmath to FPMATH_387 when SSE is disabled.
> > > >
> > > > gcc/testsuite/
> > > >
> > > >         PR target/89397
> > > >         * gcc.target/i386/pr89397.c: New test.
> > >
> > > OK.
> > >
> >
> > This patch is need to fix:
> >
> > FAIL: gcc.target/i386/pr67985-3.c scan-assembler movd[ \t]%xmm[0-7], %eax
> > FAIL: gcc.target/i386/pr67985-3.c scan-assembler mulss
> >
> > OK for trunk?
> 
> PR 67985 says:
> 
> --q--
> Since -miamcu specifies how parameters are passed to functions,
> inside function, we can use any instructions -march= allows.
> -miamcu -march=haswell should allow x87 and AVX instructions
> --/q--
> 
> The command line specifies -mfpmath=sse and target attribute implies
> SSE. So, SSE instructions should be used here. Please investigate why
> this is not the case.
> 

Here is the patch.


H.J.
---
On x86, SSE and 387 can be used for FP math, which is controlled by
-mfpmath=[sse|387].  If ISA seleted by -mfpmath is disabled, we switch
FP math to the alternate ISA only if it is available.  When both SSE
and 387 are disabled, we leave FP math choice unchanged.  We require
SSE for SSE FP math so that no SSE instructions will be generated
without SSE and SSE FP math can be enabled with target attribute.

	PR target/89397
	* config/i386/i386.c (ix86_option_override_internal): Revert
	r269017.
	* config/i386/i386.h (TARGET_SSE_MATH): Require SSE.
---
 gcc/config/i386/i386.c | 7 ++++---
 gcc/config/i386/i386.h | 3 ++-
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Uros Bizjak Feb. 20, 2019, 2:44 p.m. UTC | #1
On Wed, Feb 20, 2019 at 3:35 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Wed, Feb 20, 2019 at 08:12:35AM +0100, Uros Bizjak wrote:
> > On Tue, Feb 19, 2019 at 9:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > On Tue, Feb 19, 2019 at 6:16 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> > > >
> > > > On Tue, Feb 19, 2019 at 2:49 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > > >
> > > > > ix86_fpmath should be set to combination of FPMATH_387 and FPMATH_SSE.
> > > > > When SSE is disabled, it should be set to FPMATH_387 and 387 codegen is
> > > > > also controlled by -msoft-float.
> > > > >
> > > > > gcc/
> > > > >
> > > > >         PR target/89397
> > > > >         * config/i386/i386.c (ix86_option_override_internal): Set
> > > > >         opts->x_ix86_fpmath to FPMATH_387 when SSE is disabled.
> > > > >
> > > > > gcc/testsuite/
> > > > >
> > > > >         PR target/89397
> > > > >         * gcc.target/i386/pr89397.c: New test.
> > > >
> > > > OK.
> > > >
> > >
> > > This patch is need to fix:
> > >
> > > FAIL: gcc.target/i386/pr67985-3.c scan-assembler movd[ \t]%xmm[0-7], %eax
> > > FAIL: gcc.target/i386/pr67985-3.c scan-assembler mulss
> > >
> > > OK for trunk?
> >
> > PR 67985 says:
> >
> > --q--
> > Since -miamcu specifies how parameters are passed to functions,
> > inside function, we can use any instructions -march= allows.
> > -miamcu -march=haswell should allow x87 and AVX instructions
> > --/q--
> >
> > The command line specifies -mfpmath=sse and target attribute implies
> > SSE. So, SSE instructions should be used here. Please investigate why
> > this is not the case.
> >
>
> Here is the patch.
>
>
> H.J.
> ---
> On x86, SSE and 387 can be used for FP math, which is controlled by
> -mfpmath=[sse|387].  If ISA seleted by -mfpmath is disabled, we switch
> FP math to the alternate ISA only if it is available.  When both SSE
> and 387 are disabled, we leave FP math choice unchanged.  We require
> SSE for SSE FP math so that no SSE instructions will be generated
> without SSE and SSE FP math can be enabled with target attribute.
>
>         PR target/89397
>         * config/i386/i386.c (ix86_option_override_internal): Revert
>         r269017.
>         * config/i386/i386.h (TARGET_SSE_MATH): Require SSE.
> ---
>  gcc/config/i386/i386.c | 7 ++++---
>  gcc/config/i386/i386.h | 3 ++-
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index bed17330fa8..591a7cdccdc 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -4310,9 +4310,10 @@ ix86_option_override_internal (bool main_args_p,
>           if (!TARGET_SSE_P (opts->x_ix86_isa_flags))
>             {
>               if (TARGET_80387_P (opts->x_target_flags))
> -               warning (0, "SSE instruction set disabled, using 387 arithmetics");
> -             /* NB: 387 codegen is guarded by TARGET_80387.  */
> -             opts->x_ix86_fpmath = FPMATH_387;
> +               {
> +                 warning (0, "SSE instruction set disabled, using 387 arithmetics");
> +                 opts->x_ix86_fpmath = FPMATH_387;
> +               }
>             }
>           else if ((opts->x_ix86_fpmath & FPMATH_387)
>                    && !TARGET_80387_P (opts->x_target_flags))
> diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> index 4fd8bc40a34..7a80e8bd026 100644
> --- a/gcc/config/i386/i386.h
> +++ b/gcc/config/i386/i386.h
> @@ -590,7 +590,8 @@ extern unsigned char x86_prefetch_sse;
>
>  #define ASSEMBLER_DIALECT      (ix86_asm_dialect)
>
> -#define TARGET_SSE_MATH                ((ix86_fpmath & FPMATH_SSE) != 0)
> +#define TARGET_SSE_MATH \
> +  ((ix86_fpmath & FPMATH_SSE) != 0 && TARGET_SSE)

No.

Uros.

>  #define TARGET_MIX_SSE_I387 \
>   ((ix86_fpmath & (FPMATH_SSE | FPMATH_387)) == (FPMATH_SSE | FPMATH_387))
>
> --
> 2.20.1
>
H.J. Lu Feb. 20, 2019, 2:46 p.m. UTC | #2
On Wed, Feb 20, 2019 at 6:44 AM Uros Bizjak <ubizjak@gmail.com> wrote:
>
> On Wed, Feb 20, 2019 at 3:35 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> >
> > On Wed, Feb 20, 2019 at 08:12:35AM +0100, Uros Bizjak wrote:
> > > On Tue, Feb 19, 2019 at 9:14 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > >
> > > > On Tue, Feb 19, 2019 at 6:16 AM Uros Bizjak <ubizjak@gmail.com> wrote:
> > > > >
> > > > > On Tue, Feb 19, 2019 at 2:49 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > > > > >
> > > > > > ix86_fpmath should be set to combination of FPMATH_387 and FPMATH_SSE.
> > > > > > When SSE is disabled, it should be set to FPMATH_387 and 387 codegen is
> > > > > > also controlled by -msoft-float.
> > > > > >
> > > > > > gcc/
> > > > > >
> > > > > >         PR target/89397
> > > > > >         * config/i386/i386.c (ix86_option_override_internal): Set
> > > > > >         opts->x_ix86_fpmath to FPMATH_387 when SSE is disabled.
> > > > > >
> > > > > > gcc/testsuite/
> > > > > >
> > > > > >         PR target/89397
> > > > > >         * gcc.target/i386/pr89397.c: New test.
> > > > >
> > > > > OK.
> > > > >
> > > >
> > > > This patch is need to fix:
> > > >
> > > > FAIL: gcc.target/i386/pr67985-3.c scan-assembler movd[ \t]%xmm[0-7], %eax
> > > > FAIL: gcc.target/i386/pr67985-3.c scan-assembler mulss
> > > >
> > > > OK for trunk?
> > >
> > > PR 67985 says:
> > >
> > > --q--
> > > Since -miamcu specifies how parameters are passed to functions,
> > > inside function, we can use any instructions -march= allows.
> > > -miamcu -march=haswell should allow x87 and AVX instructions
> > > --/q--
> > >
> > > The command line specifies -mfpmath=sse and target attribute implies
> > > SSE. So, SSE instructions should be used here. Please investigate why
> > > this is not the case.
> > >
> >
> > Here is the patch.
> >
> >
> > H.J.
> > ---
> > On x86, SSE and 387 can be used for FP math, which is controlled by
> > -mfpmath=[sse|387].  If ISA seleted by -mfpmath is disabled, we switch
> > FP math to the alternate ISA only if it is available.  When both SSE
> > and 387 are disabled, we leave FP math choice unchanged.  We require
> > SSE for SSE FP math so that no SSE instructions will be generated
> > without SSE and SSE FP math can be enabled with target attribute.
> >
> >         PR target/89397
> >         * config/i386/i386.c (ix86_option_override_internal): Revert
> >         r269017.
> >         * config/i386/i386.h (TARGET_SSE_MATH): Require SSE.
> > ---
> >  gcc/config/i386/i386.c | 7 ++++---
> >  gcc/config/i386/i386.h | 3 ++-
> >  2 files changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index bed17330fa8..591a7cdccdc 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -4310,9 +4310,10 @@ ix86_option_override_internal (bool main_args_p,
> >           if (!TARGET_SSE_P (opts->x_ix86_isa_flags))
> >             {
> >               if (TARGET_80387_P (opts->x_target_flags))
> > -               warning (0, "SSE instruction set disabled, using 387 arithmetics");
> > -             /* NB: 387 codegen is guarded by TARGET_80387.  */
> > -             opts->x_ix86_fpmath = FPMATH_387;
> > +               {
> > +                 warning (0, "SSE instruction set disabled, using 387 arithmetics");
> > +                 opts->x_ix86_fpmath = FPMATH_387;
> > +               }
> >             }
> >           else if ((opts->x_ix86_fpmath & FPMATH_387)
> >                    && !TARGET_80387_P (opts->x_target_flags))
> > diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
> > index 4fd8bc40a34..7a80e8bd026 100644
> > --- a/gcc/config/i386/i386.h
> > +++ b/gcc/config/i386/i386.h
> > @@ -590,7 +590,8 @@ extern unsigned char x86_prefetch_sse;
> >
> >  #define ASSEMBLER_DIALECT      (ix86_asm_dialect)
> >
> > -#define TARGET_SSE_MATH                ((ix86_fpmath & FPMATH_SSE) != 0)
> > +#define TARGET_SSE_MATH \
> > +  ((ix86_fpmath & FPMATH_SSE) != 0 && TARGET_SSE)
>
> No.

Either this patch or adjust gcc.target/i386/pr67985-3.c.

> Uros.
>
> >  #define TARGET_MIX_SSE_I387 \
> >   ((ix86_fpmath & (FPMATH_SSE | FPMATH_387)) == (FPMATH_SSE | FPMATH_387))
> >
> > --
> > 2.20.1
> >
diff mbox series

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index bed17330fa8..591a7cdccdc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4310,9 +4310,10 @@  ix86_option_override_internal (bool main_args_p,
 	  if (!TARGET_SSE_P (opts->x_ix86_isa_flags))
 	    {
 	      if (TARGET_80387_P (opts->x_target_flags))
-		warning (0, "SSE instruction set disabled, using 387 arithmetics");
-	      /* NB: 387 codegen is guarded by TARGET_80387.  */
-	      opts->x_ix86_fpmath = FPMATH_387;
+		{
+		  warning (0, "SSE instruction set disabled, using 387 arithmetics");
+		  opts->x_ix86_fpmath = FPMATH_387;
+		}
 	    }
 	  else if ((opts->x_ix86_fpmath & FPMATH_387)
 		   && !TARGET_80387_P (opts->x_target_flags))
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 4fd8bc40a34..7a80e8bd026 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -590,7 +590,8 @@  extern unsigned char x86_prefetch_sse;
 
 #define ASSEMBLER_DIALECT	(ix86_asm_dialect)
 
-#define TARGET_SSE_MATH		((ix86_fpmath & FPMATH_SSE) != 0)
+#define TARGET_SSE_MATH \
+  ((ix86_fpmath & FPMATH_SSE) != 0 && TARGET_SSE)
 #define TARGET_MIX_SSE_I387 \
  ((ix86_fpmath & (FPMATH_SSE | FPMATH_387)) == (FPMATH_SSE | FPMATH_387))