[28/42] i386: Make _mm_empty () as NOP when MMX is disabled

Message ID 20190215135812.32306-29-hjl.tools@gmail.com
State New
Headers show
Series
  • V6: Emulate MMX intrinsics with SSE
Related show

Commit Message

H.J. Lu Feb. 15, 2019, 1:57 p.m.
With SSE emulation of MMX intrinsics, we should make _mm_empty () as NOP
when MMX is disabled.

	PR target/89021
	* config/i386/mmx.md (EMMS): Also allow TARGET_MMX_WITH_SSE.
	(mmx_<emms>): Generate "<emms>" only when MMX is enabled.
---
 gcc/config/i386/mmx.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.20.1

Comments

Uros Bizjak Feb. 15, 2019, 5:23 p.m. | #1
On Fri, Feb 15, 2019 at 3:03 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> With SSE emulation of MMX intrinsics, we should make _mm_empty () as NOP

> when MMX is disabled.

>

>         PR target/89021

>         * config/i386/mmx.md (EMMS): Also allow TARGET_MMX_WITH_SSE.

>         (mmx_<emms>): Generate "<emms>" only when MMX is enabled.


Better rename the pattern to "*mmx_<emms>" and introduce a new expander:

(define_insn "mmx_<emms>"
  [(unspec_volatile [(const_int 0)] EMMS)
   (clobber (reg:XF ST0_REG))
   (clobber (reg:XF ST1_REG))
   (clobber (reg:XF ST2_REG))
   (clobber (reg:XF ST3_REG))
   (clobber (reg:XF ST4_REG))
   (clobber (reg:XF ST5_REG))
   (clobber (reg:XF ST6_REG))
   (clobber (reg:XF ST7_REG))
   (clobber (reg:DI MM0_REG))
   (clobber (reg:DI MM1_REG))
   (clobber (reg:DI MM2_REG))
   (clobber (reg:DI MM3_REG))
   (clobber (reg:DI MM4_REG))
   (clobber (reg:DI MM5_REG))
   (clobber (reg:DI MM6_REG))
   (clobber (reg:DI MM7_REG))]
  "TARGET_MMX || TARGET_MMX_WITH_SSE"
{
  if (!TARGET_MMX)
    {
      emit_insn (gen_nop ());
      DONE;
    }
})

This way, the compiler won't bother with {f,}emms when there are no
MMX registers.

Uros.

> ---

>  gcc/config/i386/mmx.md | 6 ++++--

>  1 file changed, 4 insertions(+), 2 deletions(-)

>

> diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md

> index d662663a445..eaca71d5750 100644

> --- a/gcc/config/i386/mmx.md

> +++ b/gcc/config/i386/mmx.md

> @@ -1839,7 +1839,7 @@

>     (set_attr "mode" "DI")])

>

>  (define_int_iterator EMMS

> -  [(UNSPECV_EMMS "TARGET_MMX")

> +  [(UNSPECV_EMMS "TARGET_MMX || TARGET_MMX_WITH_SSE")

>     (UNSPECV_FEMMS "TARGET_3DNOW")])

>

>  (define_int_attr emms

> @@ -1865,7 +1865,9 @@

>     (clobber (reg:DI MM6_REG))

>     (clobber (reg:DI MM7_REG))]

>    ""

> -  "<emms>"

> +{

> +  return TARGET_MMX ? "<emms>" : "";

>

> +}

>    [(set_attr "type" "mmx")

>     (set_attr "modrm" "0")

>     (set_attr "memory" "none")])

> --

> 2.20.1

>

Patch

diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
index d662663a445..eaca71d5750 100644
--- a/gcc/config/i386/mmx.md
+++ b/gcc/config/i386/mmx.md
@@ -1839,7 +1839,7 @@ 
    (set_attr "mode" "DI")])
 
 (define_int_iterator EMMS
-  [(UNSPECV_EMMS "TARGET_MMX")
+  [(UNSPECV_EMMS "TARGET_MMX || TARGET_MMX_WITH_SSE")
    (UNSPECV_FEMMS "TARGET_3DNOW")])
 
 (define_int_attr emms
@@ -1865,7 +1865,9 @@ 
    (clobber (reg:DI MM6_REG))
    (clobber (reg:DI MM7_REG))]
   ""
-  "<emms>"
+{
+  return TARGET_MMX ? "<emms>" : "";
+}
   [(set_attr "type" "mmx")
    (set_attr "modrm" "0")
    (set_attr "memory" "none")])