On Thu, Feb 14, 2019 at 12:07 PM Uros Bizjak <ubiz...@gmail.com> wrote:
>
> On Thu, Feb 14, 2019 at 1:33 PM H.J. Lu <hjl.to...@gmail.com> wrote:
> >
> > Allow MMX intrinsic emulation with SSE/SSE2/SSSE3.  Don't enable MMX ISA
> > by default with TARGET_MMX_WITH_SSE.
> >
> > For pr82483-1.c and pr82483-2.c, "-mssse3 -mno-mmx" compiles in 64-bit
> > mode since MMX intrinsics can be emulated wit SSE.
> >
> > gcc/
> >
> >         PR target/89021
> >         * config/i386/i386-builtin.def: Enable MMX intrinsics with
> >         SSE/SSE2/SSSE3.
> >         * config/i386/i386.c (ix86_option_override_internal): Don't
> >         enable MMX ISA with TARGET_MMX_WITH_SSE by default.
> >         (ix86_init_mmx_sse_builtins): Enable MMX intrinsics with
> >         SSE/SSE2/SSSE3.
> >         (ix86_expand_builtin): Allow SSE/SSE2/SSSE3 to emulate MMX
> >         intrinsics with TARGET_MMX_WITH_SSE.
> >         * config/i386/mmintrin.h: Don't require MMX in 64-bit mode.
> >

>
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index a9abbe8706b..1d417e08734 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -4165,12 +4165,15 @@ ix86_option_override_internal (bool main_args_p,
> >        opts->x_target_flags
> >         |= TARGET_SUBTARGET64_DEFAULT & ~opts_set->x_target_flags;
> >
> > -      /* Enable by default the SSE and MMX builtins.  Do allow the user to
> > -        explicitly disable any of these.  In particular, disabling SSE and
> > -        MMX for kernel code is extremely useful.  */
> > +      /* Enable the SSE and MMX builtins by default.  Don't enable MMX
> > +         ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user to
> > +        explicitly disable any of these.  In particular, disabling SSE
> > +        and MMX for kernel code is extremely useful.  */
> >        if (!ix86_arch_specified)
> >        opts->x_ix86_isa_flags
> > -       |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE | 
> > OPTION_MASK_ISA_MMX
> > +       |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
> > +            | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
> > +               ? 0 : OPTION_MASK_ISA_MMX)
> >              | TARGET_SUBTARGET64_ISA_DEFAULT)
> >              & ~opts->x_ix86_isa_flags_explicit);
>
> Please split the above into two clauses, the first that sets SSE and
> MMX by default, and the second to or with
>
> opts->x_ix86_isa_flags
>      |= TARGET_SUBTARGET64_ISA_DEFAULT & ~opts->x_ix86_isa_flags_explicit
>

Like this?

      /* Enable the SSE and MMX builtins by default.  Don't enable MMX
         ISA with TARGET_MMX_WITH_SSE by default.  Do allow the user to
         explicitly disable any of these.  In particular, disabling SSE
         and MMX for kernel code is extremely useful.  */
      if (!ix86_arch_specified)
        {
          opts->x_ix86_isa_flags
            |= ((OPTION_MASK_ISA_SSE2 | OPTION_MASK_ISA_SSE
                 | (TARGET_MMX_WITH_SSE_P (opts->x_ix86_isa_flags)
                    ? 0 : OPTION_MASK_ISA_MMX))
                & ~opts->x_ix86_isa_flags_explicit);
          opts->x_ix86_isa_flags
            |= (TARGET_SUBTARGET64_ISA_DEFAULT
                & ~opts->x_ix86_isa_flags_explicit);
        }


> > diff --git a/gcc/config/i386/mmintrin.h b/gcc/config/i386/mmintrin.h
> > index 238b3df3121..7b613658111 100644
> > --- a/gcc/config/i386/mmintrin.h
> > +++ b/gcc/config/i386/mmintrin.h
> > @@ -30,7 +30,7 @@
> >  #if defined __x86_64__ && !defined __SSE__ || !defined __MMX__
> >  #pragma GCC push_options
> >  #ifdef __x86_64__
> > -#pragma GCC target("sse,mmx")
> > +#pragma GCC target("sse2")
>
> You will need to involve __MMX_WITH_SSE__ here, probably to something like:
>
> #ifdef __MMX_WITH_SSE__
> #pragma GCC target("sse2")
> #elif defined __x86_64__
> #pragma GCC target("sse,mmx")
> #else
> #pragma GCC target("mmx")
> #endif
>
> >  #else
> >  #pragma GCC target("mmx")
> >  #endif
> > @@ -315,7 +315,11 @@ _m_paddd (__m64 __m1, __m64 __m2)
> >  /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
> >  #ifndef __SSE2__
> >  #pragma GCC push_options
> > +#ifdef __x86_64__
>
> #ifdef __MMX_WITH_SSE__
>
> > +#pragma GCC target("sse2")
> > +#else
> >  #pragma GCC target("sse2,mmx")
> > +#endif
> >  #define __DISABLE_SSE2__
> >  #endif /* __SSE2__ */
> >
> > @@ -427,7 +431,11 @@ _m_psubd (__m64 __m1, __m64 __m2)
> >  /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
> >  #ifndef __SSE2__
> >  #pragma GCC push_options
> > +#ifdef __x86_64__
>
> #ifdef __MMX_WITH_SSE__
>
> > +#pragma GCC target("sse2")
> > +#else
> >  #pragma GCC target("sse2,mmx")
> > +#endif
> >  #define __DISABLE_SSE2__
> >  #endif /* __SSE2__ */
> >
> > diff --git a/gcc/testsuite/gcc.target/i386/pr82483-1.c 
> > b/gcc/testsuite/gcc.target/i386/pr82483-1.c

I will do

diff --git a/gcc/config/i386/mmintrin.h b/gcc/config/i386/mmintrin.h
index 238b3df3121..c4b2e0c7b25 100644
--- a/gcc/config/i386/mmintrin.h
+++ b/gcc/config/i386/mmintrin.h
@@ -29,7 +29,9 @@

 #if defined __x86_64__ && !defined __SSE__ || !defined __MMX__
 #pragma GCC push_options
-#ifdef __x86_64__
+#ifdef __MMX_WITH_SSE__
+#pragma GCC target("sse2")
+#elif defined __x86_64__
 #pragma GCC target("sse,mmx")
 #else
 #pragma GCC target("mmx")
@@ -315,7 +317,11 @@ _m_paddd (__m64 __m1, __m64 __m2)
 /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
 #ifndef __SSE2__
 #pragma GCC push_options
+#ifdef __MMX_WITH_SSE__
+#pragma GCC target("sse2")
+#else
 #pragma GCC target("sse2,mmx")
+#endif
 #define __DISABLE_SSE2__
 #endif /* __SSE2__ */

@@ -427,7 +433,11 @@ _m_psubd (__m64 __m1, __m64 __m2)
 /* Add the 64-bit values in M1 to the 64-bit values in M2.  */
 #ifndef __SSE2__
 #pragma GCC push_options
+#ifdef __MMX_WITH_SSE__
+#pragma GCC target("sse2")
+#else
 #pragma GCC target("sse2,mmx")
+#endif
 #define __DISABLE_SSE2__
 #endif

Thanks.

-- 
H.J.

Reply via email to