[rs6000] Testcase coverage for vec_splats

Message ID 1507580156.26707.136.camel@brimstone.rchland.ibm.com
State New
Headers show
Series
  • [rs6000] Testcase coverage for vec_splats
Related show

Commit Message

Will Schmidt Oct. 9, 2017, 8:15 p.m.
[PATCH, rs6000] Testcase coverage for vec_splats
    
Add testcase coverage for bec_splat built-ins.
Tested across power6 and newer. 
OK for trunk?

Thanks, 
-Will
    
[testsuite]
	* gcc.target/powerpc/fold-vec-splats-char.c: New.
	* gcc.target/powerpc/fold-vec-splats-floatdouble.c: New.
	* gcc.target/powerpc/fold-vec-splats-int.c: New.
	* gcc.target/powerpc/fold-vec-splats-longlong.c: New.
	* gcc.target/powerpc/fold-vec-splats-short.c: New.

Comments

Segher Boessenkool Oct. 9, 2017, 9:39 p.m. | #1
Hi Will,

On Mon, Oct 09, 2017 at 03:15:56PM -0500, Will Schmidt wrote:
> +/* { dg-final { scan-assembler-times "xscvdpspn|xscvdpsp" 1 } } */
> +/* { dg-final { scan-assembler-times "vspltw|xxspltw" 1 } } */

The second of these (xscvdpsp) will match whenever the first (xscvdpspn)
does.  Maybe you should use something like {\mxscvdpspn?\M} ?

Okay with that fixed.  Thanks!


Segher

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-char.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-char.c
new file mode 100644
index 0000000..8f21153
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-char.c
@@ -0,0 +1,22 @@ 
+/* Verify that overloaded built-ins for vec_splats() with char
+   inputs produce the right code.  */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -O2 " } */
+
+#include <altivec.h>
+
+vector signed char
+test1s (signed char x)
+{
+  return vec_splats (x);
+}
+
+vector unsigned char
+test1u (unsigned char x)
+{
+  return vec_splats (x);
+}
+
+/* { dg-final { scan-assembler-times "vspltb" 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-floatdouble.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-floatdouble.c
new file mode 100644
index 0000000..859bb38
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-floatdouble.c
@@ -0,0 +1,27 @@ 
+/* Verify that overloaded built-ins for vec_splat with float and
+   double inputs for VSX produce the right code.  */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-mvsx -O1" } */
+
+#include <altivec.h>
+
+vector float
+test1d (float x)
+{
+  return vec_splats (x);
+}
+
+vector double
+test1f (double x)
+{
+  return vec_splats (x);
+}
+
+// float test generates the permute instruction.
+/* { dg-final { scan-assembler-times "xxpermdi" 1 } } */
+
+// double test generates a convert (double to single non-signalling) followed by a splat.
+/* { dg-final { scan-assembler-times "xscvdpspn|xscvdpsp" 1 } } */
+/* { dg-final { scan-assembler-times "vspltw|xxspltw" 1 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-int.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-int.c
new file mode 100644
index 0000000..6671523
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-int.c
@@ -0,0 +1,22 @@ 
+/* Verify that overloaded built-ins for vec_splat with int
+   inputs produce the right code.  */
+
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -O2 " } */
+
+#include <altivec.h>
+
+vector signed int
+test3s (signed int x)
+{
+  return vec_splats (x);
+}
+
+vector unsigned int
+test3u (unsigned int x)
+{
+  return vec_splats (x);
+}
+
+/* { dg-final { scan-assembler-times {\mvspltw\M|\mxxspltw\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-longlong.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-longlong.c
new file mode 100644
index 0000000..c5884ba
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-longlong.c
@@ -0,0 +1,22 @@ 
+/* Verify that overloaded built-ins for vec_splat with long long
+   inputs produce the right code.  */
+
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-mvsx -O2" } */
+
+#include <altivec.h>
+
+vector signed long long
+test3s (signed long long x)
+{
+  return vec_splats (x);
+}
+
+vector unsigned long long
+test3u (unsigned long long x)
+{
+  return vec_splats (x);
+}
+
+/* { dg-final { scan-assembler-times "xxpermdi" 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-short.c b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-short.c
new file mode 100644
index 0000000..18102ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splats-short.c
@@ -0,0 +1,23 @@ 
+/* Verify that overloaded built-ins for vec_splat with short
+   inputs produce the right code.  */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -O2" } */
+
+#include <altivec.h>
+
+vector signed short
+test3s (signed short x)
+{
+  return vec_splats (x);
+}
+
+vector unsigned short
+test3u (unsigned short x)
+{
+  return vec_splats (x);
+}
+
+/* { dg-final { scan-assembler-times "vsplth" 2 } } */
+