public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256
@ 2022-09-27 23:34 H.J. Lu
  2022-09-28  1:41 ` Hongtao Liu
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2022-09-27 23:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: Hongyu Wang, Hongtao Liu, Uros Bizjak

encodekey128 and encodekey256 operations clear XMM4-XMM6.  But it is
documented that XMM4-XMM6 are reserved for future usages and software
should not rely upon them being zeroed.  Change encodekey128 and
encodekey256 to clobber XMM4-XMM6.

gcc/

	PR target/107061
	* config/i386/predicates.md (encodekey128_operation): Check
	XMM4-XMM6 as clobbered.
	(encodekey256_operation): Likewise.
	* config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6.
	(encodekey256u32): Likewise.

gcc/testsuite/

	PR target/107061
	* gcc.target/i386/keylocker-encodekey128.c: Don't check
	XMM4-XMM6.
	* gcc.target/i386/keylocker-encodekey256.c: Likewise.
---
 gcc/config/i386/predicates.md                 | 20 +++++++++----------
 gcc/config/i386/sse.md                        |  4 ++--
 .../gcc.target/i386/keylocker-encodekey128.c  |  1 -
 .../gcc.target/i386/keylocker-encodekey256.c  |  1 -
 4 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 655eabf793b..c4141a96735 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -2107,11 +2107,11 @@ (define_predicate "encodekey128_operation"
   for(i = 4; i < 7; i++)
     {
       elt = XVECEXP (op, 0, i);
-      if (GET_CODE (elt) != SET
-	  || GET_CODE (SET_DEST (elt)) != REG
-	  || GET_MODE (SET_DEST (elt)) != V2DImode
-	  || REGNO (SET_DEST (elt)) != GET_SSE_REGNO (i)
-	  || SET_SRC (elt) != CONST0_RTX (V2DImode))
+      if (GET_CODE (elt) != CLOBBER
+	  || GET_MODE (elt) != VOIDmode
+	  || GET_CODE (XEXP (elt, 0)) != REG
+	  || GET_MODE (XEXP (elt, 0)) != V2DImode
+	  || REGNO (XEXP (elt, 0)) != GET_SSE_REGNO (i))
 	return false;
     }
 
@@ -2157,11 +2157,11 @@ (define_predicate "encodekey256_operation"
   for(i = 4; i < 7; i++)
     {
       elt = XVECEXP (op, 0, i + 1);
-      if (GET_CODE (elt) != SET
-	  || GET_CODE (SET_DEST (elt)) != REG
-	  || GET_MODE (SET_DEST (elt)) != V2DImode
-	  || REGNO (SET_DEST (elt)) != GET_SSE_REGNO (i)
-	  || SET_SRC (elt) != CONST0_RTX (V2DImode))
+      if (GET_CODE (elt) != CLOBBER
+	  || GET_MODE (elt) != VOIDmode
+	  || GET_CODE (XEXP (elt, 0)) != REG
+	  || GET_MODE (XEXP (elt, 0)) != V2DImode
+	  || REGNO (XEXP (elt, 0)) != GET_SSE_REGNO (i))
 	return false;
     }
 
diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index 5c189635124..076064f97e6 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -29015,7 +29015,7 @@ (define_expand "encodekey128u32"
 
   for (i = 4; i < 7; i++)
     XVECEXP (operands[2], 0, i)
-      = gen_rtx_SET (xmm_regs[i], CONST0_RTX (V2DImode));
+      = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]);
 
   XVECEXP (operands[2], 0, 7)
     = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
@@ -29072,7 +29072,7 @@ (define_expand "encodekey256u32"
 
   for (i = 4; i < 7; i++)
     XVECEXP (operands[2], 0, i + 1)
-      = gen_rtx_SET (xmm_regs[i], CONST0_RTX (V2DImode));
+      = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]);
 
   XVECEXP (operands[2], 0, 8)
     = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
diff --git a/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c b/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c
index 805e0628673..57fa9bdc831 100644
--- a/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c
+++ b/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c
@@ -6,7 +6,6 @@
 /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm0,\[^\\n\\r\]*" } } */
 /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm1,\[^\\n\\r\]*16\[^\\n\\r\]*" } } */
 /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm2,\[^\\n\\r\]*32\[^\\n\\r\]*" } } */
-/* { dg-final { scan-assembler "(?:movdqa|movaps)\[ \\t\]+\[^\\n\]*%xmm\[4-6\],\[^\\n\\r\]*" } } */
 
 #include <immintrin.h>
 
diff --git a/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c b/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c
index 26f04dcf014..a9398b4e7a2 100644
--- a/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c
+++ b/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c
@@ -8,7 +8,6 @@
 /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm1,\[^\\n\\r\]*16\[^\\n\\r\]*" } } */
 /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm2,\[^\\n\\r\]*32\[^\\n\\r\]*" } } */
 /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm3,\[^\\n\\r\]*48\[^\\n\\r\]*" } } */
-/* { dg-final { scan-assembler "(?:movdqa|movaps)\[ \\t\]+\[^\\n\]*%xmm\[4-6\],\[^\\n\\r\]*" } } */
 
 #include <immintrin.h>
 
-- 
2.37.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256
  2022-09-27 23:34 [PATCH] i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256 H.J. Lu
@ 2022-09-28  1:41 ` Hongtao Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Hongtao Liu @ 2022-09-28  1:41 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, Hongtao Liu, Hongyu Wang

On Wed, Sep 28, 2022 at 7:35 AM H.J. Lu via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> encodekey128 and encodekey256 operations clear XMM4-XMM6.  But it is
> documented that XMM4-XMM6 are reserved for future usages and software
> should not rely upon them being zeroed.  Change encodekey128 and
Indeed. Ok for trunk and backport.
> encodekey256 to clobber XMM4-XMM6.
>
> gcc/
>
>         PR target/107061
>         * config/i386/predicates.md (encodekey128_operation): Check
>         XMM4-XMM6 as clobbered.
>         (encodekey256_operation): Likewise.
>         * config/i386/sse.md (encodekey128u32): Clobber XMM4-XMM6.
>         (encodekey256u32): Likewise.
>
> gcc/testsuite/
>
>         PR target/107061
>         * gcc.target/i386/keylocker-encodekey128.c: Don't check
>         XMM4-XMM6.
>         * gcc.target/i386/keylocker-encodekey256.c: Likewise.
> ---
>  gcc/config/i386/predicates.md                 | 20 +++++++++----------
>  gcc/config/i386/sse.md                        |  4 ++--
>  .../gcc.target/i386/keylocker-encodekey128.c  |  1 -
>  .../gcc.target/i386/keylocker-encodekey256.c  |  1 -
>  4 files changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
> index 655eabf793b..c4141a96735 100644
> --- a/gcc/config/i386/predicates.md
> +++ b/gcc/config/i386/predicates.md
> @@ -2107,11 +2107,11 @@ (define_predicate "encodekey128_operation"
>    for(i = 4; i < 7; i++)
>      {
>        elt = XVECEXP (op, 0, i);
> -      if (GET_CODE (elt) != SET
> -         || GET_CODE (SET_DEST (elt)) != REG
> -         || GET_MODE (SET_DEST (elt)) != V2DImode
> -         || REGNO (SET_DEST (elt)) != GET_SSE_REGNO (i)
> -         || SET_SRC (elt) != CONST0_RTX (V2DImode))
> +      if (GET_CODE (elt) != CLOBBER
> +         || GET_MODE (elt) != VOIDmode
> +         || GET_CODE (XEXP (elt, 0)) != REG
> +         || GET_MODE (XEXP (elt, 0)) != V2DImode
> +         || REGNO (XEXP (elt, 0)) != GET_SSE_REGNO (i))
>         return false;
>      }
>
> @@ -2157,11 +2157,11 @@ (define_predicate "encodekey256_operation"
>    for(i = 4; i < 7; i++)
>      {
>        elt = XVECEXP (op, 0, i + 1);
> -      if (GET_CODE (elt) != SET
> -         || GET_CODE (SET_DEST (elt)) != REG
> -         || GET_MODE (SET_DEST (elt)) != V2DImode
> -         || REGNO (SET_DEST (elt)) != GET_SSE_REGNO (i)
> -         || SET_SRC (elt) != CONST0_RTX (V2DImode))
> +      if (GET_CODE (elt) != CLOBBER
> +         || GET_MODE (elt) != VOIDmode
> +         || GET_CODE (XEXP (elt, 0)) != REG
> +         || GET_MODE (XEXP (elt, 0)) != V2DImode
> +         || REGNO (XEXP (elt, 0)) != GET_SSE_REGNO (i))
>         return false;
>      }
>
> diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
> index 5c189635124..076064f97e6 100644
> --- a/gcc/config/i386/sse.md
> +++ b/gcc/config/i386/sse.md
> @@ -29015,7 +29015,7 @@ (define_expand "encodekey128u32"
>
>    for (i = 4; i < 7; i++)
>      XVECEXP (operands[2], 0, i)
> -      = gen_rtx_SET (xmm_regs[i], CONST0_RTX (V2DImode));
> +      = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]);
>
>    XVECEXP (operands[2], 0, 7)
>      = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
> @@ -29072,7 +29072,7 @@ (define_expand "encodekey256u32"
>
>    for (i = 4; i < 7; i++)
>      XVECEXP (operands[2], 0, i + 1)
> -      = gen_rtx_SET (xmm_regs[i], CONST0_RTX (V2DImode));
> +      = gen_rtx_CLOBBER (VOIDmode, xmm_regs[i]);
>
>    XVECEXP (operands[2], 0, 8)
>      = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, FLAGS_REG));
> diff --git a/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c b/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c
> index 805e0628673..57fa9bdc831 100644
> --- a/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c
> +++ b/gcc/testsuite/gcc.target/i386/keylocker-encodekey128.c
> @@ -6,7 +6,6 @@
>  /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm0,\[^\\n\\r\]*" } } */
>  /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm1,\[^\\n\\r\]*16\[^\\n\\r\]*" } } */
>  /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm2,\[^\\n\\r\]*32\[^\\n\\r\]*" } } */
> -/* { dg-final { scan-assembler "(?:movdqa|movaps)\[ \\t\]+\[^\\n\]*%xmm\[4-6\],\[^\\n\\r\]*" } } */
>
>  #include <immintrin.h>
>
> diff --git a/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c b/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c
> index 26f04dcf014..a9398b4e7a2 100644
> --- a/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c
> +++ b/gcc/testsuite/gcc.target/i386/keylocker-encodekey256.c
> @@ -8,7 +8,6 @@
>  /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm1,\[^\\n\\r\]*16\[^\\n\\r\]*" } } */
>  /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm2,\[^\\n\\r\]*32\[^\\n\\r\]*" } } */
>  /* { dg-final { scan-assembler "(?:movdqu|movups)\[ \\t\]+\[^\\n\]*%xmm3,\[^\\n\\r\]*48\[^\\n\\r\]*" } } */
> -/* { dg-final { scan-assembler "(?:movdqa|movaps)\[ \\t\]+\[^\\n\]*%xmm\[4-6\],\[^\\n\\r\]*" } } */
>
>  #include <immintrin.h>
>
> --
> 2.37.3
>


-- 
BR,
Hongtao

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-28  1:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-27 23:34 [PATCH] i386: Mark XMM4-XMM6 as clobbered by encodekey128/encodekey256 H.J. Lu
2022-09-28  1:41 ` Hongtao Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).