public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] rs6000: Accept const pointer operands for MMA builtins [PR109073]
@ 2023-03-08 23:01 Peter Bergner
  2023-03-09  9:30 ` Kewen.Lin
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Bergner @ 2023-03-08 23:01 UTC (permalink / raw)
  To: GCC Patches; +Cc: Segher Boessenkool, Chip Kerchner

PR109073 shows a problem where GCC 11 and GCC 10 do not accept a const
__vector_pair pointer operand to some MMA builtins, which GCC 12 and later
correctly accept.  Fixed here by initializing the builtins to accept const
pointers.

This patch was tested in both GCC 11 and GCC 10 on powerpc64le-linux and
showed no regressions.  Ok for backports?

Peter


gcc/

	PR target/109073
	* config/rs6000/rs6000-call.c (mma_init_builtins): Accept const pointer
	operands for lxvp, stxvp and disassemble builtins.

gcc/testsuite/

	PR target/109073
	* gcc.target/powerpc/mma-builtin-4.c): New const * test. Update
	expected instruction counts.
	* gcc.target/powerpc/mma-builtin-5.c: Likewise.
	* gcc.target/powerpc/mma-builtin-7.c: Likewise.


diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
index 1be4797e834..3b6d40f0aef 100644
--- a/gcc/config/rs6000/rs6000-call.c
+++ b/gcc/config/rs6000/rs6000-call.c
@@ -14343,22 +14343,30 @@ mma_init_builtins (void)
 	{
 	  op[nopnds++] = build_pointer_type (void_type_node);
 	  if (d->code == MMA_BUILTIN_DISASSEMBLE_ACC)
-	    op[nopnds++] = build_pointer_type (vector_quad_type_node);
+	    op[nopnds++] = build_pointer_type (build_qualified_type
+						 (vector_quad_type_node,
+						  TYPE_QUAL_CONST));
 	  else
-	    op[nopnds++] = build_pointer_type (vector_pair_type_node);
+	    op[nopnds++] = build_pointer_type (build_qualified_type
+						 (vector_pair_type_node,
+						  TYPE_QUAL_CONST));
 	}
       else if (d->code == VSX_BUILTIN_LXVP)
 	{
 	  op[nopnds++] = vector_pair_type_node;
 	  op[nopnds++] = sizetype;
-	  op[nopnds++] = build_pointer_type (vector_pair_type_node);
+	  op[nopnds++] = build_pointer_type (build_qualified_type
+					       (vector_pair_type_node,
+						TYPE_QUAL_CONST));
 	}
       else if (d->code == VSX_BUILTIN_STXVP)
 	{
 	  op[nopnds++] = void_type_node;
 	  op[nopnds++] = vector_pair_type_node;
 	  op[nopnds++] = sizetype;
-	  op[nopnds++] = build_pointer_type (vector_pair_type_node);
+	  op[nopnds++] = build_pointer_type (build_qualified_type
+					       (vector_pair_type_node,
+						TYPE_QUAL_CONST));
 	}
       else
 	{
diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c b/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c
index a9fb0107d12..0ba650fcee7 100644
--- a/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-4.c
@@ -46,6 +46,15 @@ bar2 (vec_t *dst, __vector_pair *src)
   dst[4] = res[1];
 }
 
+void
+bar3 (vec_t *dst, const __vector_pair *src)
+{
+  vec_t res[2];
+  __builtin_vsx_disassemble_pair (res, src);
+  dst[0] = res[0];
+  dst[4] = res[1];
+}
+
 #if !__has_builtin (__builtin_vsx_assemble_pair)
 #  error "__has_builtin (__builtin_vsx_assemble_pair) failed"
 #endif
@@ -67,7 +76,7 @@ bar2 (vec_t *dst, __vector_pair *src)
 #endif
 
 /* { dg-final { scan-assembler-times {\mlxv\M} 6 } } */
-/* { dg-final { scan-assembler-times {\mlxvp\M} 2 } } */
-/* { dg-final { scan-assembler-times {\mstxv\M} 4 } } */
+/* { dg-final { scan-assembler-times {\mlxvp\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mstxv\M} 6 } } */
 /* { dg-final { scan-assembler-times {\mstxvp\M} 3 } } */
 
diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c b/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c
index 00503b7343d..998c436a8bb 100644
--- a/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c
+++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-5.c
@@ -31,6 +31,17 @@ bar (vec_t *dst, __vector_quad *src)
   dst[12] = res[3];
 }
 
+void
+bar2 (vec_t *dst, const __vector_quad *src)
+{
+  vec_t res[4];
+  __builtin_mma_disassemble_acc (res, src);
+  dst[0] = res[0];
+  dst[4] = res[1];
+  dst[8] = res[2];
+  dst[12] = res[3];
+}
+
 #if !__has_builtin (__builtin_mma_assemble_acc)
 #  error "__has_builtin (__builtin_mma_assemble_acc) failed"
 #endif
@@ -40,8 +51,8 @@ bar (vec_t *dst, __vector_quad *src)
 #endif
 
 /* { dg-final { scan-assembler-times {\mlxv\M} 8 } } */
-/* { dg-final { scan-assembler-times {\mlxvp\M} 2 } } */
-/* { dg-final { scan-assembler-times {\mstxv\M} 4 } } */
+/* { dg-final { scan-assembler-times {\mlxvp\M} 4 } } */
+/* { dg-final { scan-assembler-times {\mstxv\M} 8 } } */
 /* { dg-final { scan-assembler-times {\mstxvp\M} 4 } } */
-/* { dg-final { scan-assembler-times {\mxxmfacc\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mxxmtacc\M} 3 } } */
+/* { dg-final { scan-assembler-times {\mxxmfacc\M} 4 } } */
+/* { dg-final { scan-assembler-times {\mxxmtacc\M} 4 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c b/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c
index c661a4b84bc..23becfde15e 100644
--- a/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c
+++ b/gcc/testsuite/gcc.target/powerpc/mma-builtin-7.c
@@ -14,13 +14,25 @@ foo (__vector_pair *dst, __vector_pair *src, long idx)
   dst[8] = __builtin_vsx_lxvp (257, src);
 }
 
+void
+bar (__vector_pair *dst, const __vector_pair *src, long idx)
+{
+  dst[0] = __builtin_vsx_lxvp (0, src);
+  dst[2] = __builtin_vsx_lxvp (32, src);
+  dst[4] = __builtin_vsx_lxvp (64, src);
+  /* Non-constant offset should generate a lxvpx.  */
+  dst[6] = __builtin_vsx_lxvp (idx, src);
+  /* Non-aligned offset should generate a plxvp.  */
+  dst[8] = __builtin_vsx_lxvp (257, src);
+}
+
 #if !__has_builtin (__builtin_vsx_lxvp)
 #  error "__has_builtin (__builtin_vsx_lxvp) failed"
 #endif
 
 /* { dg-final { scan-assembler-not {\mlxv\M} } } */
 /* { dg-final { scan-assembler-not {\mstxv\M} } } */
-/* { dg-final { scan-assembler-times {\mlxvp\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mlxvpx\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mplxvp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mstxvp\M} 5 } } */
+/* { dg-final { scan-assembler-times {\mlxvp\M} 6 } } */
+/* { dg-final { scan-assembler-times {\mlxvpx\M} 2 } } */
+/* { dg-final { scan-assembler-times {\mplxvp\M} 2 } } */
+/* { dg-final { scan-assembler-times {\mstxvp\M} 10 } } */

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

end of thread, other threads:[~2023-03-13 21:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 23:01 [PATCH] rs6000: Accept const pointer operands for MMA builtins [PR109073] Peter Bergner
2023-03-09  9:30 ` Kewen.Lin
2023-03-09 14:55   ` Segher Boessenkool
2023-03-10  1:24     ` Peter Bergner
2023-03-13 21:25       ` Segher Boessenkool
2023-03-13  6:55     ` Kewen.Lin

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).