x86: Use x constraint on KL patterns

Message ID 20220325205014.32895-1-hjl.tools@gmail.com
State Committed
Commit ede5f5224d55b84b9f186b288164df9c06fd85e7
Headers
Series x86: Use x constraint on KL patterns |

Commit Message

H.J. Lu March 25, 2022, 8:50 p.m. UTC
  Since KL instructions have no AVX512 version, replace the "v" register
constraint with the "x" register constraint.

	PR target/105058
	* config/i386/sse.md (loadiwkey): Replace "v" with "x".
	(aes<aesklvariant>u8): Likewise.
---
 gcc/config/i386/sse.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Hongyu Wang March 26, 2022, 1:08 a.m. UTC | #1
Is it possible to create a test case that gas would throw an error for
invalid operands?

H.J. Lu via Gcc-patches <gcc-patches@gcc.gnu.org> 于2022年3月26日周六 04:50写道:
>
> Since KL instructions have no AVX512 version, replace the "v" register
> constraint with the "x" register constraint.
>
>         PR target/105058
>         * config/i386/sse.md (loadiwkey): Replace "v" with "x".
>         (aes<aesklvariant>u8): Likewise.
> ---
>  gcc/config/i386/sse.md | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> index 29802d00ce6..33bd2c4768a 100644
> --- a/gcc/config/i386/sse.md
> +++ b/gcc/config/i386/sse.md
> @@ -28364,8 +28364,8 @@ (define_insn "avx512f_dpbf16ps_<mode>_mask"
>
>  ;; KEYLOCKER
>  (define_insn "loadiwkey"
> -  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "v")
> -                         (match_operand:V2DI 1 "register_operand" "v")
> +  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
> +                         (match_operand:V2DI 1 "register_operand" "x")
>                           (match_operand:V2DI 2 "register_operand" "Yz")
>                           (match_operand:SI   3 "register_operand" "a")]
>                          UNSPECV_LOADIWKEY)
> @@ -28498,7 +28498,7 @@ (define_int_attr aesklvariant
>     (UNSPECV_AESENC256KLU8 "enc256kl")])
>
>  (define_insn "aes<aesklvariant>u8"
> -  [(set (match_operand:V2DI 0 "register_operand" "=v")
> +  [(set (match_operand:V2DI 0 "register_operand" "=x")
>         (unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
>                                (match_operand:BLK   2 "memory_operand" "m")]
>                               AESDECENCKL))
> --
> 2.35.1
>
  
H.J. Lu March 26, 2022, 1:22 a.m. UTC | #2
On Fri, Mar 25, 2022 at 6:08 PM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote:
>
> Is it possible to create a test case that gas would throw an error for
> invalid operands?

You can use -ffix-xmmN to disable XMM0-15.

> H.J. Lu via Gcc-patches <gcc-patches@gcc.gnu.org> 于2022年3月26日周六 04:50写道:
> >
> > Since KL instructions have no AVX512 version, replace the "v" register
> > constraint with the "x" register constraint.
> >
> >         PR target/105058
> >         * config/i386/sse.md (loadiwkey): Replace "v" with "x".
> >         (aes<aesklvariant>u8): Likewise.
> > ---
> >  gcc/config/i386/sse.md | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> > index 29802d00ce6..33bd2c4768a 100644
> > --- a/gcc/config/i386/sse.md
> > +++ b/gcc/config/i386/sse.md
> > @@ -28364,8 +28364,8 @@ (define_insn "avx512f_dpbf16ps_<mode>_mask"
> >
> >  ;; KEYLOCKER
> >  (define_insn "loadiwkey"
> > -  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "v")
> > -                         (match_operand:V2DI 1 "register_operand" "v")
> > +  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
> > +                         (match_operand:V2DI 1 "register_operand" "x")
> >                           (match_operand:V2DI 2 "register_operand" "Yz")
> >                           (match_operand:SI   3 "register_operand" "a")]
> >                          UNSPECV_LOADIWKEY)
> > @@ -28498,7 +28498,7 @@ (define_int_attr aesklvariant
> >     (UNSPECV_AESENC256KLU8 "enc256kl")])
> >
> >  (define_insn "aes<aesklvariant>u8"
> > -  [(set (match_operand:V2DI 0 "register_operand" "=v")
> > +  [(set (match_operand:V2DI 0 "register_operand" "=x")
> >         (unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
> >                                (match_operand:BLK   2 "memory_operand" "m")]
> >                               AESDECENCKL))
> > --
> > 2.35.1
> >
  
Hongyu Wang March 26, 2022, 2:04 a.m. UTC | #3
> > Is it possible to create a test case that gas would throw an error for
> > invalid operands?
>
> You can use -ffix-xmmN to disable XMM0-15.

I mean can we create an intrinsic test for this PR that produces xmm16-31?
And the -ffix-xmmN is an option for assembler or compiler? I didn't
find it in document.

H.J. Lu <hjl.tools@gmail.com> 于2022年3月26日周六 09:22写道:
>
> On Fri, Mar 25, 2022 at 6:08 PM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote:
> >
> > Is it possible to create a test case that gas would throw an error for
> > invalid operands?
>
> You can use -ffix-xmmN to disable XMM0-15.
>
> > H.J. Lu via Gcc-patches <gcc-patches@gcc.gnu.org> 于2022年3月26日周六 04:50写道:
> > >
> > > Since KL instructions have no AVX512 version, replace the "v" register
> > > constraint with the "x" register constraint.
> > >
> > >         PR target/105058
> > >         * config/i386/sse.md (loadiwkey): Replace "v" with "x".
> > >         (aes<aesklvariant>u8): Likewise.
> > > ---
> > >  gcc/config/i386/sse.md | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> > > index 29802d00ce6..33bd2c4768a 100644
> > > --- a/gcc/config/i386/sse.md
> > > +++ b/gcc/config/i386/sse.md
> > > @@ -28364,8 +28364,8 @@ (define_insn "avx512f_dpbf16ps_<mode>_mask"
> > >
> > >  ;; KEYLOCKER
> > >  (define_insn "loadiwkey"
> > > -  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "v")
> > > -                         (match_operand:V2DI 1 "register_operand" "v")
> > > +  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
> > > +                         (match_operand:V2DI 1 "register_operand" "x")
> > >                           (match_operand:V2DI 2 "register_operand" "Yz")
> > >                           (match_operand:SI   3 "register_operand" "a")]
> > >                          UNSPECV_LOADIWKEY)
> > > @@ -28498,7 +28498,7 @@ (define_int_attr aesklvariant
> > >     (UNSPECV_AESENC256KLU8 "enc256kl")])
> > >
> > >  (define_insn "aes<aesklvariant>u8"
> > > -  [(set (match_operand:V2DI 0 "register_operand" "=v")
> > > +  [(set (match_operand:V2DI 0 "register_operand" "=x")
> > >         (unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
> > >                                (match_operand:BLK   2 "memory_operand" "m")]
> > >                               AESDECENCKL))
> > > --
> > > 2.35.1
> > >
>
>
>
> --
> H.J.
  
H.J. Lu March 26, 2022, 2:08 a.m. UTC | #4
On Fri, Mar 25, 2022 at 7:04 PM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote:
>
> > > Is it possible to create a test case that gas would throw an error for
> > > invalid operands?
> >
> > You can use -ffix-xmmN to disable XMM0-15.
>
> I mean can we create an intrinsic test for this PR that produces xmm16-31?
> And the -ffix-xmmN is an option for assembler or compiler? I didn't
> find it in document.

You can add -march=skylake-avx512 -ffix-xmm0 ... -ffix-xmm15 to force
XMM16-XMM31.

> H.J. Lu <hjl.tools@gmail.com> 于2022年3月26日周六 09:22写道:
> >
> > On Fri, Mar 25, 2022 at 6:08 PM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote:
> > >
> > > Is it possible to create a test case that gas would throw an error for
> > > invalid operands?
> >
> > You can use -ffix-xmmN to disable XMM0-15.
> >
> > > H.J. Lu via Gcc-patches <gcc-patches@gcc.gnu.org> 于2022年3月26日周六 04:50写道:
> > > >
> > > > Since KL instructions have no AVX512 version, replace the "v" register
> > > > constraint with the "x" register constraint.
> > > >
> > > >         PR target/105058
> > > >         * config/i386/sse.md (loadiwkey): Replace "v" with "x".
> > > >         (aes<aesklvariant>u8): Likewise.
> > > > ---
> > > >  gcc/config/i386/sse.md | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> > > > index 29802d00ce6..33bd2c4768a 100644
> > > > --- a/gcc/config/i386/sse.md
> > > > +++ b/gcc/config/i386/sse.md
> > > > @@ -28364,8 +28364,8 @@ (define_insn "avx512f_dpbf16ps_<mode>_mask"
> > > >
> > > >  ;; KEYLOCKER
> > > >  (define_insn "loadiwkey"
> > > > -  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "v")
> > > > -                         (match_operand:V2DI 1 "register_operand" "v")
> > > > +  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
> > > > +                         (match_operand:V2DI 1 "register_operand" "x")
> > > >                           (match_operand:V2DI 2 "register_operand" "Yz")
> > > >                           (match_operand:SI   3 "register_operand" "a")]
> > > >                          UNSPECV_LOADIWKEY)
> > > > @@ -28498,7 +28498,7 @@ (define_int_attr aesklvariant
> > > >     (UNSPECV_AESENC256KLU8 "enc256kl")])
> > > >
> > > >  (define_insn "aes<aesklvariant>u8"
> > > > -  [(set (match_operand:V2DI 0 "register_operand" "=v")
> > > > +  [(set (match_operand:V2DI 0 "register_operand" "=x")
> > > >         (unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
> > > >                                (match_operand:BLK   2 "memory_operand" "m")]
> > > >                               AESDECENCKL))
> > > > --
> > > > 2.35.1
> > > >
> >
> >
> >
> > --
> > H.J.
  
Hongtao Liu March 26, 2022, 6:35 a.m. UTC | #5
On Sat, Mar 26, 2022 at 4:50 AM H.J. Lu via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Since KL instructions have no AVX512 version, replace the "v" register
> constraint with the "x" register constraint.
>
>         PR target/105058
>         * config/i386/sse.md (loadiwkey): Replace "v" with "x".
>         (aes<aesklvariant>u8): Likewise.
LGTM, please backport to GCC11.
> ---
>  gcc/config/i386/sse.md | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> index 29802d00ce6..33bd2c4768a 100644
> --- a/gcc/config/i386/sse.md
> +++ b/gcc/config/i386/sse.md
> @@ -28364,8 +28364,8 @@ (define_insn "avx512f_dpbf16ps_<mode>_mask"
>
>  ;; KEYLOCKER
>  (define_insn "loadiwkey"
> -  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "v")
> -                         (match_operand:V2DI 1 "register_operand" "v")
> +  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
> +                         (match_operand:V2DI 1 "register_operand" "x")
>                           (match_operand:V2DI 2 "register_operand" "Yz")
>                           (match_operand:SI   3 "register_operand" "a")]
>                          UNSPECV_LOADIWKEY)
> @@ -28498,7 +28498,7 @@ (define_int_attr aesklvariant
>     (UNSPECV_AESENC256KLU8 "enc256kl")])
>
>  (define_insn "aes<aesklvariant>u8"
> -  [(set (match_operand:V2DI 0 "register_operand" "=v")
> +  [(set (match_operand:V2DI 0 "register_operand" "=x")
>         (unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
>                                (match_operand:BLK   2 "memory_operand" "m")]
>                               AESDECENCKL))
> --
> 2.35.1
>
  
Hongtao Liu March 26, 2022, 6:51 a.m. UTC | #6
On Sat, Mar 26, 2022 at 10:05 AM Hongyu Wang via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> > > Is it possible to create a test case that gas would throw an error for
> > > invalid operands?
> >
> > You can use -ffix-xmmN to disable XMM0-15.
>
> I mean can we create an intrinsic test for this PR that produces xmm16-31?
> And the -ffix-xmmN is an option for assembler or compiler? I didn't
> find it in document.
Can be reproduced by below testcase.
 #include <immintrin.h>

 unsigned int ctrl;
 __m128i k1, k2, k3;

 void
 test_keylocker_11 (void)
 {
   register __m128i k4 __asm ("xmm16") = k2;
  asm volatile ("" : "+v" (k4));
  _mm_loadiwkey (ctrl, k1, k4, k3);
}

/tmp/ccy9VHP9.s: Assembler messages:
/tmp/ccy9VHP9.s:13: Error: unsupported instruction `loadiwkey'

>
> H.J. Lu <hjl.tools@gmail.com> 于2022年3月26日周六 09:22写道:
> >
> > On Fri, Mar 25, 2022 at 6:08 PM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote:
> > >
> > > Is it possible to create a test case that gas would throw an error for
> > > invalid operands?
> >
> > You can use -ffix-xmmN to disable XMM0-15.
> >
> > > H.J. Lu via Gcc-patches <gcc-patches@gcc.gnu.org> 于2022年3月26日周六 04:50写道:
> > > >
> > > > Since KL instructions have no AVX512 version, replace the "v" register
> > > > constraint with the "x" register constraint.
> > > >
> > > >         PR target/105058
> > > >         * config/i386/sse.md (loadiwkey): Replace "v" with "x".
> > > >         (aes<aesklvariant>u8): Likewise.
> > > > ---
> > > >  gcc/config/i386/sse.md | 6 +++---
> > > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > > >
> > > > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> > > > index 29802d00ce6..33bd2c4768a 100644
> > > > --- a/gcc/config/i386/sse.md
> > > > +++ b/gcc/config/i386/sse.md
> > > > @@ -28364,8 +28364,8 @@ (define_insn "avx512f_dpbf16ps_<mode>_mask"
> > > >
> > > >  ;; KEYLOCKER
> > > >  (define_insn "loadiwkey"
> > > > -  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "v")
> > > > -                         (match_operand:V2DI 1 "register_operand" "v")
> > > > +  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
> > > > +                         (match_operand:V2DI 1 "register_operand" "x")
> > > >                           (match_operand:V2DI 2 "register_operand" "Yz")
> > > >                           (match_operand:SI   3 "register_operand" "a")]
> > > >                          UNSPECV_LOADIWKEY)
> > > > @@ -28498,7 +28498,7 @@ (define_int_attr aesklvariant
> > > >     (UNSPECV_AESENC256KLU8 "enc256kl")])
> > > >
> > > >  (define_insn "aes<aesklvariant>u8"
> > > > -  [(set (match_operand:V2DI 0 "register_operand" "=v")
> > > > +  [(set (match_operand:V2DI 0 "register_operand" "=x")
> > > >         (unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
> > > >                                (match_operand:BLK   2 "memory_operand" "m")]
> > > >                               AESDECENCKL))
> > > > --
> > > > 2.35.1
> > > >
> >
> >
> >
> > --
> > H.J.
  

Patch

diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 29802d00ce6..33bd2c4768a 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -28364,8 +28364,8 @@  (define_insn "avx512f_dpbf16ps_<mode>_mask"
 
 ;; KEYLOCKER
 (define_insn "loadiwkey"
-  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "v")
-			  (match_operand:V2DI 1 "register_operand" "v")
+  [(unspec_volatile:V2DI [(match_operand:V2DI 0 "register_operand" "x")
+			  (match_operand:V2DI 1 "register_operand" "x")
 			  (match_operand:V2DI 2 "register_operand" "Yz")
 			  (match_operand:SI   3 "register_operand" "a")]
 			 UNSPECV_LOADIWKEY)
@@ -28498,7 +28498,7 @@  (define_int_attr aesklvariant
    (UNSPECV_AESENC256KLU8 "enc256kl")])
 
 (define_insn "aes<aesklvariant>u8"
-  [(set (match_operand:V2DI 0 "register_operand" "=v")
+  [(set (match_operand:V2DI 0 "register_operand" "=x")
 	(unspec_volatile:V2DI [(match_operand:V2DI 1 "register_operand" "0")
 			       (match_operand:BLK   2 "memory_operand" "m")]
 			      AESDECENCKL))