+2017-10-10 Will Schmidt <will_schmidt@vnet.ibm.com>
+
+ * 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.
+
2017-10-10 Jakub Jelinek <jakub@redhat.com>
PR c/82437
--- /dev/null
+/* 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 } } */
--- /dev/null
+/* 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 {\mxscvdpspn?\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mvspltw\M|\mxxspltw\M} 1 } } */
--- /dev/null
+/* 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 } } */
--- /dev/null
+/* 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 } } */
--- /dev/null
+/* 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 } } */
+