* [PATCH] rs6000: Update the vsx-vector-6.* tests.
@ 2023-05-30 20:46 Carl Love
2023-06-19 7:17 ` Kewen.Lin
0 siblings, 1 reply; 12+ messages in thread
From: Carl Love @ 2023-05-30 20:46 UTC (permalink / raw)
To: Kewen.Lin, Segher Boessenkool, gcc-patches; +Cc: cel, Peter Bergner
GCC maintainers:
The following patch takes the tests in vsx-vector-6-p7.h, vsx-vector-
6-p8.h, vsx-vector-6-p9.h and reorganizes them into a series of smaller
test files by functionality rather than processor version.
The patch has been tested on Power 10 with no regressions.
Please let me know if this patch is acceptable for mainline. Thanks.
Carl
------------------------------------------
rs6000: Update the vsx-vector-6.* tests.
The vsx-vector-6.h file is included into the processor specific test files
vsx-vector-6.p7.c, vsx-vector-6.p8.c, and vsx-vector-6.p9.c. The .h file
contains a large number of vsx vector builtin tests. The processor
specific files contain the number of instructions that the tests are
expected to generate for that processor. The tests are compile only.
The tests are broken up into a seriers of files for related tests. The
new tests are runnable tests to verify the builtin argument types and the
functional correctness of each test rather then verifying the type and
number of instructions generated.
gcc/testsuite/
* gcc.target/powerpc/vsx-vector-6-1op.c: New test file.
* gcc.target/powerpc/vsx-vector-6-2lop.c: New test file.
* gcc.target/powerpc/vsx-vector-6-2op.c: New test file.
* gcc.target/powerpc/vsx-vector-6-3op.c: New test file.
* gcc.target/powerpc/vsx-vector-6-cmp-all.c: New test file.
* gcc.target/powerpc/vsx-vector-6-cmp.c: New test file.
* gcc.target/powerpc/vsx-vector-6.h: Remove test file.
* gcc.target/powerpc/vsx-vector-6-p7.h: Remove test file.
* gcc.target/powerpc/vsx-vector-6-p8.h: Remove test file.
* gcc.target/powerpc/vsx-vector-6-p9.h: Remove test file.
---
.../powerpc/vsx-vector-6-func-1op.c | 319 +++++++++++++
.../powerpc/vsx-vector-6-func-2lop.c | 305 +++++++++++++
.../powerpc/vsx-vector-6-func-2op.c | 278 ++++++++++++
.../powerpc/vsx-vector-6-func-3op.c | 229 ++++++++++
.../powerpc/vsx-vector-6-func-cmp-all.c | 429 ++++++++++++++++++
.../powerpc/vsx-vector-6-func-cmp.c | 237 ++++++++++
.../gcc.target/powerpc/vsx-vector-6.h | 154 -------
.../gcc.target/powerpc/vsx-vector-6.p7.c | 43 --
.../gcc.target/powerpc/vsx-vector-6.p8.c | 43 --
.../gcc.target/powerpc/vsx-vector-6.p9.c | 42 --
10 files changed, 1797 insertions(+), 282 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2lop.c
create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2op.c
create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-3op.c
create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c
create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp.c
delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.h
delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p7.c
delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p8.c
delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p9.c
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
new file mode 100644
index 00000000000..90a360ea158
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
@@ -0,0 +1,319 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
+
+/* Functional test of the one operand vector builtins. */
+
+#include <altivec.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DEBUG 0
+
+void abort (void);
+
+int
+main () {
+ int i;
+ vector float f_src = { 125.44, 23.04, -338.56, 17.64};
+ vector float f_result;
+ vector float f_abs_expected = { 125.44, 23.04, 338.56, 17.64};
+ vector float f_ceil_expected = { 126.0, 24.0, -338, 18.0};
+ vector float f_floor_expected = { 125.0, 23.0, -339, 17.0};
+ vector float f_nearbyint_expected = { 125.0, 23.0, -339, 18.0};
+ vector float f_rint_expected = { 125.0, 23.0, -339, 18.0};
+ vector float f_sqrt_expected = { 11.2, 4.8, 18.4, 4.2};
+ vector float f_trunc_expected = { 125.0, 23.0, -338, 17};
+
+ vector double d_src = { 125.44, -338.56};
+ vector double d_result;
+ vector double d_abs_expected = { 125.44, 338.56};
+ vector double d_ceil_expected = { 126.0, -338.0};
+ vector double d_floor_expected = { 125.0, -339.0};
+ vector double d_nearbyint_expected = { 125.0, -339.0};
+ vector double d_rint_expected = { 125.0, -339.0};
+ vector double d_sqrt_expected = { 11.2, 18.4};
+ vector double d_trunc_expected = { 125.0, -338.0};
+
+ /* Abs, float */
+ f_result = vec_abs (f_src);
+
+ if ((f_result[0] != f_abs_expected[0])
+ || (f_result[1] != f_abs_expected[1])
+ || (f_result[2] != f_abs_expected[2])
+ || (f_result[3] != f_abs_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_abs (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_abs_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_abs_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_abs_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_abs_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Ceiling, float */
+ f_result = vec_ceil (f_src);
+
+ if ((f_result[0] != f_ceil_expected[0])
+ || (f_result[1] != f_ceil_expected[1])
+ || (f_result[2] != f_ceil_expected[2])
+ || (f_result[3] != f_ceil_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_ceil (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_ceil_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_ceil_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_ceil_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_ceil_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Floor, float */
+ f_result = vec_floor (f_src);
+
+ if ((f_result[0] != f_floor_expected[0])
+ || (f_result[1] != f_floor_expected[1])
+ || (f_result[2] != f_floor_expected[2])
+ || (f_result[3] != f_floor_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_floor (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_floor_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_floor_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_floor_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_floor_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Nearby int, float */
+ f_result = vec_nearbyint (f_src);
+
+ if ((f_result[0] != f_nearbyint_expected[0])
+ || (f_result[1] != f_nearbyint_expected[1])
+ || (f_result[2] != f_nearbyint_expected[2])
+ || (f_result[3] != f_nearbyint_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_nearby (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_nearbyint_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_nearbyint_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_nearbyint_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_nearbyint_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Round, float */
+ f_result = vec_rint (f_src);
+
+ if ((f_result[0] != f_rint_expected[0])
+ || (f_result[1] != f_rint_expected[1])
+ || (f_result[2] != f_rint_expected[2])
+ || (f_result[3] != f_rint_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_rint (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_rint_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_rint_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_rint_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_rint_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Square, float */
+ f_result = vec_sqrt (vec_abs(f_src));
+
+ if ((f_result[0] != f_sqrt_expected[0])
+ || (f_result[1] != f_sqrt_expected[1])
+ || (f_result[2] != f_sqrt_expected[2])
+ || (f_result[3] != f_sqrt_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_sqrt (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_sqrt_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_sqrt_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_sqrt_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_sqrt_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Truncate, float */
+ f_result = vec_trunc (f_src);
+
+ if ((f_result[0] != f_trunc_expected[0])
+ || (f_result[1] != f_trunc_expected[1])
+ || (f_result[2] != f_trunc_expected[2])
+ || (f_result[3] != f_trunc_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_trunc (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_trunc_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_trunc_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_trunc_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_trunc_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+
+ /* ABS, double */
+ d_result = vec_abs (d_src);
+
+ if ((d_result[0] != d_abs_expected[0]) || (d_result[1] != d_abs_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_abs (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_abs_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_abs_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* CEIL, double */
+ d_result = vec_ceil (d_src);
+
+ if ((d_result[0] != d_ceil_expected[0])
+ || (d_result[1] != d_ceil_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_ceil (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_ceil_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_ceil_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Floor, double */
+ d_result = vec_floor (d_src);
+
+ if ((d_result[0] != d_floor_expected[0])
+ || (d_result[1] != d_floor_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_floor (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_floor_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_floor_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Nearby int, double */
+ d_result = vec_nearbyint (d_src);
+
+ if ((d_result[0] != d_nearbyint_expected[0])
+ || (d_result[1] != d_nearbyint_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_nearbyint (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_nearbyint_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_nearbyint_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Round int, double */
+ d_result = vec_rint (d_src);
+
+ if ((d_result[0] != d_rint_expected[0])
+ || (d_result[1] != d_rint_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_rint (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_rint_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_rint_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Square root, double */
+ d_result = vec_sqrt (vec_abs(d_src));
+
+ if ((d_result[0] != d_sqrt_expected[0])
+ || (d_result[1] != d_sqrt_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_sqrt (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_sqrt_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_sqrt_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Truncate, double */
+ d_result = vec_trunc (d_src);
+
+ if ((d_result[0] != d_trunc_expected[0])
+ || (d_result[1] != d_trunc_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_trunc (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_trunc_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_trunc_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2lop.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2lop.c
new file mode 100644
index 00000000000..1055a8d7252
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2lop.c
@@ -0,0 +1,305 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
+
+/* Functional test of the two operand logical vector builtins. */
+
+#include <altivec.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DEBUG 0
+
+void abort (void);
+
+int
+main () {
+ int i;
+
+ union conv_t {
+ vector float f;
+ vector unsigned int u;
+ vector double d;
+ vector unsigned long ul;
+ } conv_result, conv_exp, conv_src_a, conv_src_b;
+
+
+ vector float f_src_a = { 1.0, 2.0, 3.0, 4.0};
+ vector float f_src_b = { 1.0, 3.0, -3.0, 2.0};
+ vector float f_result;
+ vector float f_expected;
+
+ vector double d_src_a = { 8.0, 10.0};
+ vector double d_src_b = { 12.0, 2.0};
+ vector double d_result;
+ vector double d_expected;
+
+ /* AND, float */
+ for (i = 0; i < 4; i++)
+ {
+ conv_src_a.f[i] = f_src_a[i];
+ conv_src_b.f[i] = f_src_b[i];
+ conv_exp.u[i] = conv_src_a.u[i] & conv_src_b.u[i];
+ f_expected[i] = conv_exp.f[i];
+ }
+
+ f_result = vec_and (f_src_a, f_src_b);
+ if ((f_result[0] != f_expected[0])
+ || (f_result[1] != f_expected[1])
+ || (f_result[2] != f_expected[2])
+ || (f_result[3] != f_expected[3]))
+ {
+#if DEBUG
+ printf("ERROR: vec_and (float) expected value does not match\n");
+ for (i = 0; i < 4; i++)
+ {
+ conv_result.f[i] = f_result[i];
+ printf(" expected[%d] = 0x%x; result[%d] = 0x%x\n", i,
+ conv_exp.u[i], i, conv_result.u[i]);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* ANDC, float */
+ for (i = 0; i < 4; i++)
+ {
+ conv_src_a.f[i] = f_src_a[i];
+ conv_src_b.f[i] = f_src_b[i];
+ conv_exp.u[i] = conv_src_a.u[i] & ~conv_src_b.u[i];
+ f_expected[i] = conv_exp.f[i];
+ }
+
+ f_result = vec_andc (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_expected[0])
+ || (f_result[1] != f_expected[1])
+ || (f_result[2] != f_expected[2])
+ || (f_result[3] != f_expected[3]))
+ {
+#if DEBUG
+ printf("ERROR: vec_andc (float) expected value does not match\n");
+ for (i = 0; i < 4; i++)
+ {
+ conv_result.f[i] = f_result[i];
+ printf(" expected[%d] = 0x%x; result[%d] = 0x%x\n", i,
+ conv_exp.u[i], i, conv_result.u[i]);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* NOR, max */
+ f_result = vec_nor (f_src_a, f_src_b);
+ for (i = 0; i < 4; i++)
+ {
+ conv_src_a.f[i] = f_src_a[i];
+ conv_src_b.f[i] = f_src_b[i];
+ conv_exp.u[i] = ~(conv_src_a.u[i] | conv_src_b.u[i]);
+ f_expected[i] = conv_exp.f[i];
+ }
+
+ if ((f_result[0] != f_expected[0])
+ || (f_result[1] != f_expected[1])
+ || (f_result[2] != f_expected[2])
+ || (f_result[3] != f_expected[3]))
+ {
+#if DEBUG
+ printf("ERROR: vec_nor (float) expected value does not match\n");
+ for (i = 0; i < 4; i++)
+ {
+ conv_result.f[i] = f_result[i];
+ printf(" expected[%d] = 0x%x; result[%d] = 0x%x\n", i,
+ conv_exp.u[i], i, conv_result.u[i]);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* OR, float */
+ f_result = vec_or (f_src_a, f_src_b);
+ for (i = 0; i < 4; i++)
+ {
+ conv_src_a.f[i] = f_src_a[i];
+ conv_src_b.f[i] = f_src_b[i];
+ conv_exp.u[i] = conv_src_a.u[i] | conv_src_b.u[i];
+ f_expected[i] = conv_exp.f[i];
+ }
+
+ if ((f_result[0] != f_expected[0])
+ || (f_result[1] != f_expected[1])
+ || (f_result[2] != f_expected[2])
+ || (f_result[3] != f_expected[3]))
+ {
+#if DEBUG
+ printf("ERROR: vec_or (float) expected value does not match\n");
+ for (i = 0; i < 4; i++)
+ {
+ conv_result.f[i] = f_result[i];
+ printf(" expected[%d] = 0x%x; result[%d] = 0x%x\n", i,
+ conv_exp.u[i], i, conv_result.u);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* XOR, float */
+ f_result = vec_xor (f_src_a, f_src_b);
+ for (i = 0; i < 4; i++)
+ {
+ conv_src_a.f[i] = f_src_a[i];
+ conv_src_b.f[i] = f_src_b[i];
+ conv_exp.u[i] = conv_src_a.u[i] ^ conv_src_b.u[i];
+ f_expected[i] = conv_exp.f[i];
+ }
+
+ if ((f_result[0] != f_expected[0])
+ || (f_result[1] != f_expected[1])
+ || (f_result[2] != f_expected[2])
+ || (f_result[3] != f_expected[3]))
+ {
+#if DEBUG
+ printf("ERROR: vec_xor (float) expected value does not match\n");
+ for (i = 0; i < 4; i++)
+ {
+ conv_result.f[i] = f_result[i];
+ printf(" expected[%d] = 0x%x; result[%d] = 0x%x\n", i,
+ conv_exp.u[i], i, conv_result.u);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* AND, double */
+ d_result = vec_and (d_src_a, d_src_b);
+ for (i = 0; i < 2; i++)
+ {
+ conv_src_a.d[i] = d_src_a[i];
+ conv_src_b.d[i] = d_src_b[i];
+ conv_exp.ul[i] = conv_src_a.ul[i] & conv_src_b.ul[i];
+ d_expected[i] = conv_exp.d[i];
+ }
+
+ if ((d_result[0] != d_expected[0]) || (d_result[1] != d_expected[1]))
+ {
+#if DEBUG
+ printf("ERROR: vec_and (double) expected value does not match\n");
+ for (i = 0; i < 2; i++)
+ {
+ conv_result.d[i] = d_result[i];
+ printf(" expected[%d] = 0x%lx; result[%d] = 0x%lx\n", i,
+ conv_exp.ul, i, conv_result.ul);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* ANDC, double */
+ d_result = vec_andc (d_src_a, d_src_b);
+ for (i = 0; i < 2; i++)
+ {
+ conv_src_a.d[i] = d_src_a[i];
+ conv_src_b.d[i] = d_src_b[i];
+ conv_exp.ul[i] = conv_src_a.ul[i] & ~conv_src_b.ul[i];
+ d_expected[i] = conv_exp.d[i];
+ }
+
+ if ((d_result[0] != d_expected[0]) || (d_result[1] != d_expected[1]))
+ {
+#if DEBUG
+ printf("ERROR: vec_andc (double) expected value does not match\n");
+ for (i = 0; i < 4; i++)
+ {
+ conv_result.d[i] = d_result[i];
+ printf(" expected[%d] = 0x%lx; result[%d] = 0x%lx\n", i,
+ conv_exp.ul[i], i, conv_result.ul);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* NOR, double */
+ d_result = vec_nor (d_src_a, d_src_b);
+ for (i = 0; i < 2; i++)
+ {
+ conv_src_a.d[i] = d_src_a[i];
+ conv_src_b.d[i] = d_src_b[i];
+ conv_exp.ul[i] = ~(conv_src_a.ul[i] | conv_src_b.ul[i]);
+ d_expected[i] = conv_exp.d[i];
+ }
+
+ if ((d_result[0] != d_expected[0]) || (d_result[1] != d_expected[1]))
+ {
+#if DEBUG
+ printf("ERROR: vec_nor (double) expected value does not match\n");
+ for (i = 0; i < 2; i++)
+ {
+ conv_result.d[i] = d_result[i];
+ printf(" expected[%d] = 0x%lx; result[%d] = 0x%lx\n", i,
+ conv_exp.ul, i, conv_result.ul);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* OR, double */
+ d_result = vec_or (d_src_a, d_src_b);
+ for (i = 0; i < 2; i++)
+ {
+ conv_src_a.d[i] = d_src_a[i];
+ conv_src_b.d[i] = d_src_b[i];
+ conv_exp.ul[i] = conv_src_a.ul[i] | conv_src_b.ul[i];
+ d_expected[i] = conv_exp.d[i];
+ }
+
+ if ((d_result[0] != d_expected[0]) || (d_result[1] != d_expected[1]))
+ {
+#if DEBUG
+ printf("ERROR: vec_or (double) expected value does not match\n");
+ for (i = 0; i < 2; i++)
+ {
+ conv_result.f[i] = f_result[i];
+ printf(" expected[%d] = 0x%lx; result[%d] = 0x%lx\n", i,
+ conv_exp.ul, i, conv_result.ul);
+ }
+#else
+ abort();
+#endif
+ }
+
+ /* XOR, double */
+ d_result = vec_xor (d_src_a, d_src_b);
+ for (i = 0; i < 2; i++)
+ {
+ conv_src_a.d[i] = d_src_a[i];
+ conv_src_b.d[i] = d_src_b[i];
+ conv_exp.ul[i] = conv_src_a.ul[i] ^ conv_src_b.ul[i];
+ d_expected[i] = conv_exp.d[i];
+ }
+
+ if ((d_result[0] != d_expected[0]) || (d_result[1] != d_expected[1]))
+ {
+#if DEBUG
+ printf("ERROR: vec_xor (double) expected value does not match\n");
+ for (i = 0; i < 2; i++)
+ {
+ conv_result.d[i] = f_result[i];
+ printf(" expected[%d] = 0x%lx; result[%d] = 0x%lx\n", i,
+ conv_exp.ul, i, conv_result.ul);
+ }
+#else
+ abort();
+#endif
+ }
+
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2op.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2op.c
new file mode 100644
index 00000000000..0ee703b8e04
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2op.c
@@ -0,0 +1,278 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
+/* Functional test of the two operand vector builtins. */
+
+#include <altivec.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DEBUG 0
+
+void abort (void);
+
+int
+main () {
+ int i;
+ vector float f_src_a = { 126.0, 23.0, -338.0, 17.0};
+ vector float f_src_b = { 2.00, -4.0, 1.0, 4.0};
+ vector float f_result;
+ vector float f_add_expected = { 128.0, 19.0, -337.0, 21.0};
+ vector float f_div_expected = { 63.0, -5.75, -338, 4.25};
+ vector float f_max_expected = { 126.0, 23.0, 1.0, 17.0};
+ vector float f_min_expected = { 2.0, -4.0, -338.0, 4.0};
+ vector float f_mul_expected = { 252, -92.0, -338, 68.0};
+ vector float f_sub_expected = { 124.0, 27.0, -339.0, 13.0};
+
+ vector double d_src_a = { 125.44, -338.56};
+ vector double d_src_b = { 4.0, -2.0};
+ vector double d_result;
+ vector double d_add_expected = { 129.44, -340.56};
+ vector double d_div_expected = { 31.360000, 169.280000};
+ vector double d_max_expected = { 125.44, -2.0};
+ vector double d_min_expected = { 4.0, -338.56};
+ vector double d_mul_expected = { 501.760000, 677.120000};
+ vector double d_sub_expected = { 121.440000, -336.560000};
+
+ /* Add, float */
+ f_result = vec_add (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_add_expected[0])
+ || (f_result[1] != f_add_expected[1])
+ || (f_result[2] != f_add_expected[2])
+ || (f_result[3] != f_add_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_add (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_add_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_add_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_add_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_add_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Divide, float */
+ f_result = vec_div (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_div_expected[0])
+ || (f_result[1] != f_div_expected[1])
+ || (f_result[2] != f_div_expected[2])
+ || (f_result[3] != f_div_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_div (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_div_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_div_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_div_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_div_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Floor, max */
+ f_result = vec_max (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_max_expected[0])
+ || (f_result[1] != f_max_expected[1])
+ || (f_result[2] != f_max_expected[2])
+ || (f_result[3] != f_max_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_max(float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_max_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_max_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_max_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_max_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Minimum, float */
+ f_result = vec_min (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_min_expected[0])
+ || (f_result[1] != f_min_expected[1])
+ || (f_result[2] != f_min_expected[2])
+ || (f_result[3] != f_min_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_min (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_min_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_min_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_min_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_min_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Multiply, float */
+ f_result = vec_mul (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_mul_expected[0])
+ || (f_result[1] != f_mul_expected[1])
+ || (f_result[2] != f_mul_expected[2])
+ || (f_result[3] != f_mul_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_mult (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_mul_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_mul_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_mul_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_mul_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Subtract, float */
+ f_result = vec_sub (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_sub_expected[0])
+ || (f_result[1] != f_sub_expected[1])
+ || (f_result[2] != f_sub_expected[2])
+ || (f_result[3] != f_sub_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_sub (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_sub_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_sub_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_sub_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_sub_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+
+
+ /* Add, double */
+ d_result = vec_add (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_add_expected[0]) || (d_result[1] != d_add_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_add (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_add_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_add_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Divide, double */
+ d_result = vec_div (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_div_expected[0])
+ || (d_result[1] != d_div_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_div (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_div_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_div_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Max */
+ d_result = vec_max (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_max_expected[0])
+ || (d_result[1] != d_max_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_max (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_max_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_max_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Nearby min */
+ d_result = vec_min (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_min_expected[0]) || (d_result[1] != d_min_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_min (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_min_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_min_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Multiply, double */
+ d_result = vec_mul (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_mul_expected[0])
+ || (d_result[1] != d_mul_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_mul (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_mul_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_mul_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Subract root, double */
+ d_result = vec_sub (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_sub_expected[0])
+ || (d_result[1] != d_sub_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_sub (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_sub_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_sub_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-3op.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-3op.c
new file mode 100644
index 00000000000..a2127455f79
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-3op.c
@@ -0,0 +1,229 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
+
+/* Functional test of the three operand vector builtins. */
+
+#include <altivec.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DEBUG 0
+
+void abort (void);
+
+int
+main () {
+ int i;
+
+ // vector unsigned char uc_src_c = {0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8,
+ // 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0};
+ vector unsigned char uc_src_c = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+ 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF};
+ vector short ss_src_a = { 1, 2, 3, 4, 5, 6, 7, 8};
+ vector short ss_src_b = { -10, 20, 30, 40, 50, 60, 70, 80};
+ vector int si_src_c = { 13, -27, 39, 48};
+ vector int si_result;
+ vector int si_expected = {43, 223, 649, 1178};
+ vector unsigned short us_src_a = { 31, 32, 33, 34, 1, 2, 3, 4};
+ vector unsigned short us_src_b = { 11, 7, 30, 90, 39, 48, 28, 64};
+ vector unsigned int ui_src_c = { 13, 17, 39, 91};
+
+ vector unsigned int ui_result;
+ vector unsigned int ui_expected = {578, 4067, 174, 431};
+ vector float f_src_a = { 126.0, 23.0, -338.0, 17.0};
+ vector float f_src_b = { 2.0, -4.0, 1.0, 4.0};
+ vector float f_src_c = { 6.0, -8.0, 7.0, 5.0};
+ vector float f_result;
+ vector float f_madd_expected = { 258.0, -100.0, -331.0, 73.0};
+ vector float f_msub_expected = { 246.0, -84.0, -345.0, 63.0};
+
+ vector unsigned long long ull_src_c = {0xFFFFFFFFFFFFFFFF,
+ 0xFFFFFFFFFFFFFFFF};
+ vector bool long long bll_src_c = {0, 0};
+ vector double d_src_a = { 125.44, -338.56};
+ vector double d_src_b = { 4.0, -2.0};
+ vector double d_src_c = { 7.0, -3.0};
+ vector double d_result;
+ vector double d_madd_expected = { 508.76, 674.12};
+ vector double d_msub_expected = { 494.76, 680.12};
+ vector double d_selectb_expected = { 125.44, -338.56};
+ vector double d_selectu_expected = { 4.0, -2.0};
+ vector double d_perm_expected = { 125.44, -338.56};
+
+ /* Vecotr multiply-sum saturated */
+ ui_result = vec_msums (us_src_a, us_src_b, ui_src_c);
+ if ((ui_result[0] != ui_expected[0])
+ || (ui_result[1] != ui_expected[1])
+ || (ui_result[2] != ui_expected[2])
+ || (ui_result[3] != ui_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_msums (unsigned) expected value does not match\n");
+ printf(" expected[0] = %d; result[0] = %d\n",
+ ui_expected[0], ui_result[0]);
+ printf(" expected[1] = %d; result[1] = %d\n",
+ ui_expected[1], ui_result[1]);
+ printf(" expected[2] = %d; result[2] = %d\n",
+ ui_expected[2], ui_result[2]);
+ printf(" expected[3] = %d; result[3] = %d\n",
+ ui_expected[3], ui_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ si_result = vec_msums (ss_src_a, ss_src_b, si_src_c);
+ if ((si_result[0] != si_expected[0])
+ || (si_result[1] != si_expected[1])
+ || (si_result[2] != si_expected[2])
+ || (si_result[3] != si_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_msums (signed) expected value does not match\n");
+ printf(" expected[0] = %d; result[0] = %d\n",
+ si_expected[0], si_result[0]);
+ printf(" expected[1] = %d; result[1] = %d\n",
+ si_expected[1], si_result[1]);
+ printf(" expected[2] = %d; result[2] = %d\n",
+ si_expected[2], si_result[2]);
+ printf(" expected[3] = %d; result[3] = %d\n",
+ si_expected[3], si_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Add, float */
+ f_result = vec_madd (f_src_a, f_src_b, f_src_c);
+
+ if ((f_result[0] != f_madd_expected[0])
+ || (f_result[1] != f_madd_expected[1])
+ || (f_result[2] != f_madd_expected[2])
+ || (f_result[3] != f_madd_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_madd (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_madd_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_madd_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_madd_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_madd_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Subtract, float */
+ f_result = vec_msub (f_src_a, f_src_b, f_src_c);
+
+ if ((f_result[0] != f_msub_expected[0])
+ || (f_result[1] != f_msub_expected[1])
+ || (f_result[2] != f_msub_expected[2])
+ || (f_result[3] != f_msub_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_msub (float) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ f_msub_expected[0], f_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ f_msub_expected[1], f_result[1]);
+ printf(" expected[2] = %f; result[2] = %f\n",
+ f_msub_expected[2], f_result[2]);
+ printf(" expected[3] = %f; result[3] = %f\n",
+ f_msub_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+
+ /* Add, double */
+ d_result = vec_madd (d_src_a, d_src_b, d_src_c);
+
+ if ((d_result[0] != d_madd_expected[0])
+ || (d_result[1] != d_madd_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_madd (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_madd_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_madd_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Subract root, double */
+ d_result = vec_msub (d_src_a, d_src_b, d_src_c);
+
+ if ((d_result[0] != d_msub_expected[0])
+ || (d_result[1] != d_msub_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_msub (double) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_msub_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_msub_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Vector select */
+ d_result = vec_sel (d_src_a, d_src_b, ull_src_c);
+
+ if ((d_result[0] != d_selectu_expected[0])
+ || (d_result[1] != d_selectu_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_msub (double, unsigned) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_selectu_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_selectu_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ d_result = vec_sel (d_src_a, d_src_b, bll_src_c);
+
+ if ((d_result[0] != d_selectb_expected[0])
+ || (d_result[1] != d_selectb_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_msub (double, bool) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_selectb_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_selectb_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Vector permute */
+ d_result = vec_perm (d_src_a, d_src_b, uc_src_c);
+
+ if ((d_result[0] != d_perm_expected[0])
+ || (d_result[1] != d_perm_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_perf (unsigned char) expected value does not match\n");
+ printf(" expected[0] = %f; result[0] = %f\n",
+ d_perm_expected[0], d_result[0]);
+ printf(" expected[1] = %f; result[1] = %f\n",
+ d_perm_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c
new file mode 100644
index 00000000000..4558918058e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c
@@ -0,0 +1,429 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
+
+/* Functional test of the vector compare all builtins. */
+
+#include <altivec.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#define DEBUG 0
+
+void abort (void);
+
+int
+main () {
+ int i;
+ vector float f_src_a = {126.0, 23.0, -338.0, 17.0};
+ vector float f_src_b = {2.00, 23.0, 1.0, 4.0};
+ bool f_result;
+ bool f_all_eq_expected = 0;
+ bool f_all_gt_expected = 0;
+ bool f_all_ge_expected = 0;
+ bool f_all_lt_expected = 0;
+ bool f_all_le_expected = 0;
+ bool f_all_nan_expected = 0;
+ bool f_all_numeric_expected = 1;
+ bool f_any_eq_expected = 1;
+ bool f_any_gt_expected = 1;
+ bool f_any_ge_expected = 1;
+ bool f_any_lt_expected = 1;
+ bool f_any_le_expected = 1;
+ bool f_any_nan_expected = 0;
+ bool f_any_numeric_expected = 1;
+
+ vector double d_src_a = { 125.44, -338.56};
+ vector double d_src_b = d_src_a;
+ bool d_result;
+ bool d_all_eq_expected = 1;
+ bool d_all_gt_expected = 0;
+ bool d_all_ge_expected = 1;
+ bool d_all_lt_expected = 0;
+ bool d_all_le_expected = 1;
+ bool d_all_nan_expected = 0;
+ bool d_all_numeric_expected = 1;
+ bool d_any_eq_expected = 1;
+ bool d_any_gt_expected = 0;
+ bool d_any_ge_expected = 1;
+ bool d_any_lt_expected = 0;
+ bool d_any_le_expected = 1;
+ bool d_any_nan_expected = 0;
+ bool d_any_numeric_expected = 1;
+
+ /* Compare all equal, float */
+ f_result = vec_all_eq (f_src_a, f_src_b);
+
+ if (f_result != f_all_eq_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_eq (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n",
+ f_all_eq_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all greater than, float */
+ f_result = vec_all_gt (f_src_a, f_src_b);
+
+ if (f_result != f_all_gt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_gt (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n",
+ f_all_gt_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all greater than or equal, float */
+ f_result = vec_all_ge (f_src_a, f_src_b);
+
+ if (f_result != f_all_ge_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_ge(float) expected value does not match\n");
+ printf(" expected] = %d; result = %d\n", f_all_ge_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all less than, float */
+ f_result = vec_all_lt (f_src_a, f_src_b);
+
+ if (f_result != f_all_lt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_lt (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_all_lt_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all less than or equal, float */
+ f_result = vec_all_le (f_src_a, f_src_b);
+
+ if (f_result != f_all_le_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_le (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_all_le_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* All NaN, float */
+ f_result = vec_all_nan (f_src_a);
+
+ if (f_result != f_all_nan_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_le (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_all_nan_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* All numeric, float */
+ f_result = vec_all_numeric (f_src_a);
+
+ if (f_result != f_all_numeric_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_numeric (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_all_numeric_expected,
+ f_result);
+ }
+#else
+ abort();
+#endif
+
+
+ /* Compare any equal, float */
+ f_result = vec_any_eq (f_src_a, f_src_b);
+
+ if (f_result != f_any_eq_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_eq (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n",
+ f_any_eq_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any greater than, float */
+ f_result = vec_any_gt (f_src_a, f_src_b);
+
+ if (f_result != f_any_gt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_gt (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n",
+ f_any_gt_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any greater than or equal, float */
+ f_result = vec_any_ge (f_src_a, f_src_b);
+
+ if (f_result != f_any_ge_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_ge(float) expected value does not match\n");
+ printf(" expected] = %d; result = %d\n", f_any_ge_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any less than, float */
+ f_result = vec_any_lt (f_src_a, f_src_b);
+
+ if (f_result != f_any_lt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_lt (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_any_lt_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any less than or equal, float */
+ f_result = vec_any_le (f_src_a, f_src_b);
+
+ if (f_result != f_any_le_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_le (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_any_le_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Any NaN, float */
+ f_result = vec_any_nan (f_src_a);
+
+ if (f_result != f_any_nan_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_le (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_any_nan_expected, f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Any numeric, float */
+ f_result = vec_any_numeric (f_src_a);
+
+ if (f_result != f_any_numeric_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_numeric (float) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", f_any_numeric_expected,
+ f_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all equal, double */
+ d_result = vec_all_eq (d_src_a, d_src_b);
+
+ if (d_result != d_all_eq_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_eq (double) expected value does not match\n");
+ printf(" expected] = %d; result = %d\n", d_all_eq_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all greater than, double */
+ d_result = vec_all_gt (d_src_a, d_src_b);
+
+ if (d_result != d_all_gt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_gt (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_all_gt_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all greater than or equal, double */
+ d_result = vec_all_ge (d_src_a, d_src_b);
+
+ if (d_result != d_all_ge_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_ge (double) expected value does not match\n");
+ printf(" expected] = %d; result = %d\n", d_all_gt_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all less than, double */
+ d_result = vec_all_lt (d_src_a, d_src_b);
+
+ if (d_result != d_all_lt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_lt (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_all_lt_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare all less than or equal, double */
+ d_result = vec_all_le (d_src_a, d_src_b);
+
+ if (d_result != d_all_le_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_le (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_all_le_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* All NaN, double */
+ d_result = vec_all_nan (d_src_a);
+
+ if (d_result != d_all_nan_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_nan (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_all_nan_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* All numeric double */
+ d_result = vec_all_numeric (d_src_a);
+
+ if (d_result != d_all_numeric_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_all_numeric (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_all_numeric_expected,
+ d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any equal, double */
+ d_result = vec_any_eq (d_src_a, d_src_b);
+
+ if (d_result != d_any_eq_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_eq (double) expected value does not match\n");
+ printf(" expected] = %d; result = %d\n", d_any_eq_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any greater than, double */
+ d_result = vec_any_gt (d_src_a, d_src_b);
+
+ if (d_result != d_any_gt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_gt (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_any_gt_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any greater than or equal, double */
+ d_result = vec_any_ge (d_src_a, d_src_b);
+
+ if (d_result != d_any_ge_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_ge (double) expected value does not match\n");
+ printf(" expected] = %d; result = %d\n", d_any_gt_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any less than, double */
+ d_result = vec_any_lt (d_src_a, d_src_b);
+
+ if (d_result != d_any_lt_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_lt (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_any_lt_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare any less than or equal, double */
+ d_result = vec_any_le (d_src_a, d_src_b);
+
+ if (d_result != d_any_le_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_le (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_any_le_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Any NaN, float */
+ d_result = vec_any_nan (d_src_a);
+
+ if (d_result != d_any_nan_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_nan (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_any_nan_expected, d_result);
+ }
+#else
+ abort();
+#endif
+
+ /* Any numeric, double */
+ d_result = vec_any_numeric (d_src_a);
+
+ if (d_result != d_any_numeric_expected)
+#if DEBUG
+ {
+ printf("ERROR: vec_any_numeric (double) expected value does not match\n");
+ printf(" expected = %d; result = %d\n", d_any_numeric_expected,
+ d_result);
+ }
+#else
+ abort();
+#endif
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp.c
new file mode 100644
index 00000000000..3c2c1861754
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp.c
@@ -0,0 +1,237 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } } */
+/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
+
+/* Functional test of the vector compare builtins. */
+
+#include <altivec.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define DEBUG 0
+
+void abort (void);
+
+int
+main () {
+ int i;
+ vector float f_src_a = { 126.0, 23.0, -338.0, 17.0};
+ vector float f_src_b = { 2.00, 23.0, 1.0, 4.0};
+ vector bool int f_result;
+ vector bool int f_cmpeq_expected = {0x0, 0xFFFFFFFF, 0x0, 0x0};
+ vector bool int f_cmpgt_expected = {0xFFFFFFFF, 0x0, 0x0, 0xFFFFFFFF};
+ vector bool int f_cmpge_expected = {0xFFFFFFFF, 0xFFFFFFFF, 0x0, 0xFFFFFFFF};
+ vector bool int f_cmplt_expected = {0x0, 0x0, 0xFFFFFFFF, 0x0};
+ vector bool int f_cmple_expected = {0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0x0};
+
+ vector double d_src_a = { 125.44, -338.56};
+ vector double d_src_b = { 4.0, -338.56};
+ vector bool long long d_result;
+ vector bool long long d_cmpeq_expected = {0x0, 0xFFFFFFFFFFFFFFFF};
+ vector bool long long d_cmpgt_expected = {0xFFFFFFFFFFFFFFFF, 0x0};
+ vector bool long long d_cmpge_expected = {0xFFFFFFFFFFFFFFFF,
+ 0xFFFFFFFFFFFFFFFF};
+ vector bool long long d_cmplt_expected = {0x0, 0x0};
+ vector bool long long d_cmple_expected = {0x0, 0xFFFFFFFFFFFFFFFF};
+
+ /* Compare equal, float */
+ f_result = vec_cmpeq (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_cmpeq_expected[0])
+ || (f_result[1] != f_cmpeq_expected[1])
+ || (f_result[2] != f_cmpeq_expected[2])
+ || (f_result[3] != f_cmpeq_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmpeq (float) expected value does not match\n");
+ printf(" expected[0] = 0x%x; result[0] =0x%x\n",
+ f_cmpeq_expected[0], f_result[0]);
+ printf(" expected[1] = 0x%x; result[1] = 0x%x\n",
+ f_cmpeq_expected[1], f_result[1]);
+ printf(" expected[2] = 0x%x; result[2] = 0x%x\n",
+ f_cmpeq_expected[2], f_result[2]);
+ printf(" expected[3] = 0x%x; result[3] = 0x%x\n",
+ f_cmpeq_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare greater than, float */
+ f_result = vec_cmpgt (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_cmpgt_expected[0])
+ || (f_result[1] != f_cmpgt_expected[1])
+ || (f_result[2] != f_cmpgt_expected[2])
+ || (f_result[3] != f_cmpgt_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmpgt (float) expected value does not match\n");
+ printf(" expected[0] = 0x%x; result[0] = 0x%x\n",
+ f_cmpgt_expected[0], f_result[0]);
+ printf(" expected[1] = 0x%x; result[1] = 0x%x\n",
+ f_cmpgt_expected[1], f_result[1]);
+ printf(" expected[2] = 0x%x; result[2] = 0x%x\n",
+ f_cmpgt_expected[2], f_result[2]);
+ printf(" expected[3] = 0x%x; result[3] = 0x%x\n",
+ f_cmpgt_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare greater than or equal, float */
+ f_result = vec_cmpge (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_cmpge_expected[0])
+ || (f_result[1] != f_cmpge_expected[1])
+ || (f_result[2] != f_cmpge_expected[2])
+ || (f_result[3] != f_cmpge_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmpge(float) expected value does not match\n");
+ printf(" expected[0] = 0x%x; result[0] = 0x%x\n",
+ f_cmpge_expected[0], f_result[0]);
+ printf(" expected[1] = 0x%x; result[1] = 0x%x\n",
+ f_cmpge_expected[1], f_result[1]);
+ printf(" expected[2] = 0x%x; result[2] = 0x%x\n",
+ f_cmpge_expected[2], f_result[2]);
+ printf(" expected[3] = 0x%x; result[3] = 0x%x\n",
+ f_cmpge_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare less than, float */
+ f_result = vec_cmplt (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_cmplt_expected[0])
+ || (f_result[1] != f_cmplt_expected[1])
+ || (f_result[2] != f_cmplt_expected[2])
+ || (f_result[3] != f_cmplt_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmplt (float) expected value does not match\n");
+ printf(" expected[0] = 0x%x; result[0] = 0x%x\n",
+ f_cmplt_expected[0], f_result[0]);
+ printf(" expected[1] = 0x%x; result[1] = 0x%x\n",
+ f_cmplt_expected[1], f_result[1]);
+ printf(" expected[2] = 0x%x; result[2] = 0x%x\n",
+ f_cmplt_expected[2], f_result[2]);
+ printf(" expected[3] = 0x%x; result[3] = 0x%x\n",
+ f_cmplt_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare less than or equal, float */
+ f_result = vec_cmple (f_src_a, f_src_b);
+
+ if ((f_result[0] != f_cmple_expected[0])
+ || (f_result[1] != f_cmple_expected[1])
+ || (f_result[2] != f_cmple_expected[2])
+ || (f_result[3] != f_cmple_expected[3]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmple (float) expected value does not match\n");
+ printf(" expected[0] = 0x%x; result[0] = 0x%x\n",
+ f_cmple_expected[0], f_result[0]);
+ printf(" expected[1] = 0x%x; result[1] = 0x%x\n",
+ f_cmple_expected[1], f_result[1]);
+ printf(" expected[2] = 0x%x; result[2] = 0x%x\n",
+ f_cmple_expected[2], f_result[2]);
+ printf(" expected[3] = 0x%x; result[3] = 0x%x\n",
+ f_cmple_expected[3], f_result[3]);
+ }
+#else
+ abort();
+#endif
+
+
+ /* Compare equal, double */
+ d_result = vec_cmpeq (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_cmpeq_expected[0]) || (d_result[1] != d_cmpeq_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmpeq (double) expected value does not match\n");
+ printf(" expected[0] = 0x%lx; result[0] = 0x%lx\n",
+ d_cmpeq_expected[0], d_result[0]);
+ printf(" expected[1] = 0x%lx; result[1] = 0x%lx\n",
+ d_cmpeq_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare greater than, double */
+ d_result = vec_cmpgt (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_cmpgt_expected[0])
+ || (d_result[1] != d_cmpgt_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmpgt (double) expected value does not match\n");
+ printf(" expected[0] = 0x%lx; result[0] = 0x%lx\n",
+ d_cmpgt_expected[0], d_result[0]);
+ printf(" expected[1] = 0x%lx; result[1] = 0x%lx\n",
+ d_cmpgt_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare greater than or equal, double */
+ d_result = vec_cmpge (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_cmpge_expected[0])
+ || (d_result[1] != d_cmpge_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmpge (double) expected value does not match\n");
+ printf(" expected[0] = 0x%lx; result[0] = 0x%lx\n",
+ d_cmpgt_expected[0], d_result[0]);
+ printf(" expected[1] = 0x%lx; result[1] = 0x%lx\n",
+ d_cmpgt_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare less than, double */
+ d_result = vec_cmplt (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_cmplt_expected[0])
+ || (d_result[1] != d_cmplt_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmplt (double) expected value does not match\n");
+ printf(" expected[0] = 0x%lx; result[0] = 0x%lx\n",
+ d_cmplt_expected[0], d_result[0]);
+ printf(" expected[1] = 0x%lx; result[1] = 0x%lx\n",
+ d_cmplt_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+
+ /* Compare less than or equal, double */
+ d_result = vec_cmple (d_src_a, d_src_b);
+
+ if ((d_result[0] != d_cmple_expected[0])
+ || (d_result[1] != d_cmple_expected[1]))
+#if DEBUG
+ {
+ printf("ERROR: vec_cmple (double) expected value does not match\n");
+ printf(" expected[0] = 0x%lx; result[0] = 0x%lx\n",
+ d_cmple_expected[0], d_result[0]);
+ printf(" expected[1] = 0x%lx; result[1] = 0x%lx\n",
+ d_cmple_expected[1], d_result[1]);
+ }
+#else
+ abort();
+#endif
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.h b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.h
deleted file mode 100644
index 0106e8d2901..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* This test code is included into vsx-vector-6.p7.c, vsx-vector-6.p8.c
- and vsx-vector-6.p9.c. The .c files have the tests for the number
- of instructions generated for each cpu type. */
-
-#include <altivec.h>
-
-typedef struct {
- vector double d;
- vector float f;
- vector long sl;
- vector int si;
- vector short ss;
- vector char sc;
- vector unsigned int ui;
- vector unsigned short int us;
- vector unsigned char uc;
- vector bool long long bll;
- vector bool long bl;
- vector bool int bi;
- vector bool short bs;
- vector bool char bc;
-} opnd_t;
-
-void
-func_1op (opnd_t *dst, opnd_t *src)
-{
- dst[0].d = vec_abs (src[0].d);
- dst[1].d = vec_ceil (src[1].d);
- dst[2].d = vec_floor (src[2].d);
- dst[3].d = vec_nearbyint (src[3].d);
- dst[4].d = vec_rint (src[4].d);
- dst[5].d = vec_sqrt (src[5].d);
- dst[6].d = vec_trunc (src[6].d);
- dst[7].f = vec_trunc (src[7].f);
-}
-
-void
-func_2op (opnd_t *dst, opnd_t *src0, opnd_t *src1)
-{
- dst[0].d = vec_add (src0[0].d, src1[0].d);
- dst[1].d = vec_div (src0[1].d, src1[1].d);
- dst[2].d = vec_max (src0[2].d, src1[2].d);
- dst[3].uc = vec_max (src0[3].uc, src1[3].uc);
- dst[4].d = vec_min (src0[4].d, src1[4].d);
- dst[5].d = vec_mul (src0[5].d, src1[5].d);
- dst[6].d = vec_sub (src0[6].d, src1[6].d);
-}
-
-void
-func_2lop (opnd_t *dst, opnd_t *src0, opnd_t *src1)
-{
- dst[0].d = vec_and (src0[0].d, src1[0].d);
- dst[1].d = vec_and (src0[1].d, src1[1].bl);
- dst[2].d = vec_and (src0[2].bl, src1[2].d);
-
- dst[3].d = vec_andc (src0[3].d, src1[3].d);
- dst[4].d = vec_andc (src0[4].d, src1[4].bl);
- dst[5].d = vec_andc (src0[5].bl, src1[5].d);
- dst[6].d = vec_andc (src0[6].bll, src1[6].d);
- dst[7].d = vec_andc (src0[7].d, src1[7].bll);
- dst[8].bi = vec_andc (src0[8].bi, src1[8].bi);
- dst[9].bs = vec_andc (src0[9].bs, src1[9].bs);
- dst[10].bc = vec_andc (src0[10].bc, src1[10].bc);
- dst[11].f = vec_andc (src0[11].f, src1[11].f);
- dst[12].f = vec_andc (src0[12].bi, src1[12].f);
- dst[13].f = vec_andc (src0[13].f, src1[13].bi);
- dst[14].d = vec_andc (src0[14].bll, src1[14].d);
- dst[15].d = vec_andc (src0[15].d, src1[15].bll);
-
- dst[16].d = vec_nor (src0[16].d, src1[16].d);
- dst[17].f = vec_nor (src0[17].f, src1[17].f);
- dst[18].bi = vec_nor (src0[18].bi, src1[18].bi);
- dst[19].bs = vec_nor (src0[19].bs, src1[19].bs);
- dst[20].bc = vec_nor (src0[20].bc, src1[20].bc);
-
- dst[21].d = vec_or (src0[21].d, src1[21].d);
- dst[22].d = vec_or (src0[22].d, src1[22].bl);
- dst[23].d = vec_or (src0[23].bl, src1[23].d);
- dst[24].d = vec_or (src0[24].bll, src1[24].d);
- dst[25].d = vec_or (src0[25].d, src1[25].bll);
- dst[26].f = vec_or (src0[26].f, src1[26].f);
- dst[27].bi = vec_or (src0[27].bi, src1[27].bi);
- dst[28].bs = vec_or (src0[28].bs, src1[28].bs);
- dst[29].bc = vec_or (src0[29].bc, src1[29].bc);
-
- dst[30].d = vec_xor (src0[30].d, src1[30].d);
- dst[31].d = vec_xor (src0[31].d, src1[31].bl);
- dst[32].d = vec_xor (src0[32].bl, src1[32].d);
-}
-
-void
-func_cmp (opnd_t *dst, opnd_t *src0, opnd_t *src1)
-{
- dst[0].bl = vec_cmpeq (src0[0].d, src1[0].d);
- dst[1].bl = vec_cmpgt (src0[1].d, src1[1].d);
- dst[2].bl = vec_cmpge (src0[2].d, src1[2].d);
- dst[3].bl = vec_cmplt (src0[3].d, src1[3].d);
- dst[4].bl = vec_cmple (src0[4].d, src1[4].d);
-}
-
-void
-func_all_cmp (int *dst, opnd_t *src0, opnd_t *src1)
-{
- dst[0] = vec_all_eq (src0[0].d, src1[0].d);
- dst[1] = vec_all_ge (src0[1].d, src1[1].d);
- dst[2] = vec_all_gt (src0[2].d, src1[2].d);
- dst[3] = vec_all_le (src0[3].d, src1[3].d);
- dst[4] = vec_all_lt (src0[4].d, src1[4].d);
- dst[5] = vec_all_nan (src0[5].d);
- dst[6] = vec_all_ne (src0[6].d, src1[6].d);
- dst[7] = vec_all_nge (src0[7].d, src1[7].d);
- dst[8] = vec_all_ngt (src0[8].d, src1[8].d);
- dst[9] = vec_all_nle (src0[9].d, src1[9].d);
- dst[10] = vec_all_nlt (src0[10].d, src1[10].d);
- dst[11] = vec_all_numeric (src0[11].d);
- dst[12] = vec_any_eq (src0[12].d, src1[12].d);
- dst[13] = vec_any_ge (src0[13].d, src1[13].d);
- dst[14] = vec_any_gt (src0[14].d, src1[14].d);
- dst[15] = vec_any_le (src0[15].d, src1[15].d);
- dst[16] = vec_any_lt (src0[16].d, src1[16].d);
- dst[17] = vec_any_nan (src0[17].d);
- dst[18] = vec_any_ne (src0[18].d, src1[18].d);
- dst[19] = vec_any_nge (src0[19].d, src1[19].d);
- dst[20] = vec_any_ngt (src0[20].d, src1[20].d);
- dst[21] = vec_any_nle (src0[21].d, src1[21].d);
- dst[22] = vec_any_nlt (src0[22].d, src1[22].d);
- dst[23] = vec_any_numeric (src0[23].d);
-}
-
-void
-func_3op (opnd_t *dst, opnd_t *src0, opnd_t *src1, opnd_t *src2)
-{
- dst[0].d = vec_madd (src0[0].d, src1[0].d, src2[0].d);
- dst[1].d = vec_msub (src0[1].d, src1[1].d, src2[1].d);
- dst[2].d = vec_nmadd (src0[2].d, src1[2].d, src2[2].d);
- dst[3].d = vec_nmsub (src0[3].d, src1[3].d, src2[3].d);
-
- dst[4].f = vec_madd (src0[4].f, src1[4].f, src2[4].f);
- dst[5].f = vec_msub (src0[5].f, src1[5].f, src2[5].f);
- dst[6].f = vec_nmsub (src0[6].f, src1[6].f, src2[6].f);
- dst[7].f = vec_nmadd (src0[7].f, src1[7].f, src2[7].f);
-
-#if defined (__BIG_ENDIAN__) || defined (_ARCH_PWR9)
- dst[8].d = vec_perm (src0[8].d, src1[8].d, src2[8].uc);
-#else
- dst[8].d = vec_perm (src0[8].d, src1[8].d, ~src2[8].uc);
-#endif
-
- dst[9].d = vec_sel (src0[9].d, src1[9].d, src2[9].d);
- dst[10].d = vec_sel (src0[10].d, src1[10].d, src2[10].bl);
-
- dst[11].si = vec_msums(src0[11].ss, src1[11].ss, src2[11].si);
- dst[12].ui = vec_msums(src0[12].us, src1[12].us, src2[12].ui);
-}
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p7.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p7.c
deleted file mode 100644
index ff560dd8d4f..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p7.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* { dg-do compile { target lp64 } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } } */
-/* { dg-require-effective-target powerpc_vsx_ok } */
-/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
-
-/* Source code for the test in vsx-vector-6.h */
-#include "vsx-vector-6.h"
-
-/* { dg-final { scan-assembler-times {\mvmaxub\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvmsumshs\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvmsumuhs\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvperm\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvabsdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvadddp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpeqdp\M} 9 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpgedp\M} 10 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpgtdp\M} 10 } } */
-/* { dg-final { scan-assembler-times {\mxvdivdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmadd[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmadd[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmaxdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmindp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmsub[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmuldp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmadd[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmadd[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmsub[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmsub[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpi\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpic\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpim\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpip\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpiz\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrspiz\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvsqrtdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvsubdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxxland\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mxxlandc\M} 13 } } */
-/* { dg-final { scan-assembler-times {\mxxlnor\M} 5 } } */
-/* { dg-final { scan-assembler-times {\mxxlor\M} 9 } } */
-/* { dg-final { scan-assembler-times {\mxxlxor\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mxxsel\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p8.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p8.c
deleted file mode 100644
index 49f5bf52af5..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p8.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* { dg-do compile { target lp64 } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } } */
-/* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-options "-O2 -mdejagnu-cpu=power8" } */
-
-/* Source code for the test in vsx-vector-6.h */
-#include "vsx-vector-6.h"
-
-/* { dg-final { scan-assembler-times {\mvmaxub\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvmsumshs\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvmsumuhs\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvperm\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvabsdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvadddp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpeqdp\M} 9 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpgedp\M} 10 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpgtdp\M} 10 } } */
-/* { dg-final { scan-assembler-times {\mxvdivdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmadd[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmadd[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmaxdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmindp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmsub[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmuldp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmadd[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmadd[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmsub[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmsub[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpi\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpic\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpim\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpip\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpiz\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrspiz\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvsqrtdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvsubdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxxland\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mxxlandc\M} 13 } } */
-/* { dg-final { scan-assembler-times {\mxxlnor\M} 5 } } */
-/* { dg-final { scan-assembler-times {\mxxlor\M} 9 } } */
-/* { dg-final { scan-assembler-times {\mxxlxor\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mxxsel\M} 2 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p9.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p9.c
deleted file mode 100644
index 3fdd9f62a4c..00000000000
--- a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p9.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* { dg-do compile { target lp64 } } */
-/* { dg-skip-if "" { powerpc*-*-darwin* } } */
-/* { dg-require-effective-target powerpc_p9vector_ok } */
-/* { dg-options "-O2 -mdejagnu-cpu=power9" } */
-
-/* Source code for the test in vsx-vector-6.h */
-#include "vsx-vector-6.h"
-
-/* { dg-final { scan-assembler-times {\mvmaxub\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvmsumshs\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mvmsumuhs\M} 1 } } */
-/* { dg-final { scan-assembler-times {\m(?:v|xx)permr?\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvabsdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvadddp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpeqdp\M} 9 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpgedp\M} 10 } } */
-/* { dg-final { scan-assembler-times {\mxvcmpgtdp\M} 10 } } */
-/* { dg-final { scan-assembler-times {\mxvdivdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmadd[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmadd[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmaxdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmindp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmsub[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmuldp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmadd[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmadd[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmsub[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvnmsub[am]sp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpi\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpic\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpim\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpip\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrdpiz\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvrspiz\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvsqrtdp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
-/* { dg-final { scan-assembler-times {\mxxland\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mxxlandc\M} 13 } } */
-/* { dg-final { scan-assembler-times {\mxxlnor\M} 5 } } */
-/* { dg-final { scan-assembler-times {\mxxlor\M} 9 } } */
-/* { dg-final { scan-assembler-times {\mxxlxor\M} 3 } } */
-/* { dg-final { scan-assembler-times {\mxxsel\M} 2 } } */
--
2.37.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-05-30 20:46 [PATCH] rs6000: Update the vsx-vector-6.* tests Carl Love
@ 2023-06-19 7:17 ` Kewen.Lin
2023-06-21 22:42 ` Carl Love
0 siblings, 1 reply; 12+ messages in thread
From: Kewen.Lin @ 2023-06-19 7:17 UTC (permalink / raw)
To: Carl Love; +Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Hi Carl,
on 2023/5/31 04:46, Carl Love wrote:
> GCC maintainers:
>
> The following patch takes the tests in vsx-vector-6-p7.h, vsx-vector-
> 6-p8.h, vsx-vector-6-p9.h and reorganizes them into a series of smaller
> test files by functionality rather than processor version.
>
> The patch has been tested on Power 10 with no regressions.
>
> Please let me know if this patch is acceptable for mainline. Thanks.
>
> Carl
>
> ------------------------------------------
> rs6000: Update the vsx-vector-6.* tests.
>
> The vsx-vector-6.h file is included into the processor specific test files
> vsx-vector-6.p7.c, vsx-vector-6.p8.c, and vsx-vector-6.p9.c. The .h file
> contains a large number of vsx vector builtin tests. The processor
> specific files contain the number of instructions that the tests are
> expected to generate for that processor. The tests are compile only.
>
> The tests are broken up into a seriers of files for related tests. The
> new tests are runnable tests to verify the builtin argument types and the
But the newly added test cases are all with "dg-do compile", it doesn't
match what you said here.
> functional correctness of each test rather then verifying the type and
> number of instructions generated.
It's good to have more coverage with runnable case, but we miss some test
coverages on the expected insn counts which cases p{7,8,9}.c can provide
originally. Unless we can ensure it's already tested somewhere else (do
we? it wasn't stated in this patch), I think we still need those checks.
>
> gcc/testsuite/
> * gcc.target/powerpc/vsx-vector-6-1op.c: New test file.
> * gcc.target/powerpc/vsx-vector-6-2lop.c: New test file.
> * gcc.target/powerpc/vsx-vector-6-2op.c: New test file.
> * gcc.target/powerpc/vsx-vector-6-3op.c: New test file.
> * gcc.target/powerpc/vsx-vector-6-cmp-all.c: New test file.
> * gcc.target/powerpc/vsx-vector-6-cmp.c: New test file.
> * gcc.target/powerpc/vsx-vector-6.h: Remove test file.
> * gcc.target/powerpc/vsx-vector-6-p7.h: Remove test file.
> * gcc.target/powerpc/vsx-vector-6-p8.h: Remove test file.
> * gcc.target/powerpc/vsx-vector-6-p9.h: Remove test file.
> ---
> .../powerpc/vsx-vector-6-func-1op.c | 319 +++++++++++++
> .../powerpc/vsx-vector-6-func-2lop.c | 305 +++++++++++++
> .../powerpc/vsx-vector-6-func-2op.c | 278 ++++++++++++
> .../powerpc/vsx-vector-6-func-3op.c | 229 ++++++++++
> .../powerpc/vsx-vector-6-func-cmp-all.c | 429 ++++++++++++++++++
> .../powerpc/vsx-vector-6-func-cmp.c | 237 ++++++++++
> .../gcc.target/powerpc/vsx-vector-6.h | 154 -------
> .../gcc.target/powerpc/vsx-vector-6.p7.c | 43 --
> .../gcc.target/powerpc/vsx-vector-6.p8.c | 43 --
> .../gcc.target/powerpc/vsx-vector-6.p9.c | 42 --
> 10 files changed, 1797 insertions(+), 282 deletions(-)
> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2lop.c
> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-2op.c
> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-3op.c
> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c
> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp.c
> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.h
> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p7.c
> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p8.c
> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.p9.c
>
> diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
> new file mode 100644
> index 00000000000..90a360ea158
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
> @@ -0,0 +1,319 @@
> +/* { dg-do compile { target lp64 } } */
> +/* { dg-skip-if "" { powerpc*-*-darwin* } } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
> +
> +/* Functional test of the one operand vector builtins. */
> +
> +#include <altivec.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#define DEBUG 0
> +
> +void abort (void);
> +
> +int
> +main () {
> + int i;
> + vector float f_src = { 125.44, 23.04, -338.56, 17.64};
> + vector float f_result;
> + vector float f_abs_expected = { 125.44, 23.04, 338.56, 17.64};
> + vector float f_ceil_expected = { 126.0, 24.0, -338, 18.0};
> + vector float f_floor_expected = { 125.0, 23.0, -339, 17.0};
> + vector float f_nearbyint_expected = { 125.0, 23.0, -339, 18.0};
> + vector float f_rint_expected = { 125.0, 23.0, -339, 18.0};
> + vector float f_sqrt_expected = { 11.2, 4.8, 18.4, 4.2};
> + vector float f_trunc_expected = { 125.0, 23.0, -338, 17};
> +
> + vector double d_src = { 125.44, -338.56};
> + vector double d_result;
> + vector double d_abs_expected = { 125.44, 338.56};
> + vector double d_ceil_expected = { 126.0, -338.0};
> + vector double d_floor_expected = { 125.0, -339.0};
> + vector double d_nearbyint_expected = { 125.0, -339.0};
> + vector double d_rint_expected = { 125.0, -339.0};
> + vector double d_sqrt_expected = { 11.2, 18.4};
> + vector double d_trunc_expected = { 125.0, -338.0};
> +
> + /* Abs, float */
> + f_result = vec_abs (f_src);
> +
> + if ((f_result[0] != f_abs_expected[0])
> + || (f_result[1] != f_abs_expected[1])
> + || (f_result[2] != f_abs_expected[2])
> + || (f_result[3] != f_abs_expected[3]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_abs (float) expected value does not match\n");
> + printf(" expected[0] = %f; result[0] = %f\n",
> + f_abs_expected[0], f_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + f_abs_expected[1], f_result[1]);
> + printf(" expected[2] = %f; result[2] = %f\n",
> + f_abs_expected[2], f_result[2]);
> + printf(" expected[3] = %f; result[3] = %f\n",
> + f_abs_expected[3], f_result[3]);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Ceiling, float */
> + f_result = vec_ceil (f_src);
> +
> + if ((f_result[0] != f_ceil_expected[0])
> + || (f_result[1] != f_ceil_expected[1])
> + || (f_result[2] != f_ceil_expected[2])
> + || (f_result[3] != f_ceil_expected[3]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_ceil (float) expected value does not match\n");
> + printf(" expected[0] = %f; result[0] = %f\n",
> + f_ceil_expected[0], f_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + f_ceil_expected[1], f_result[1]);
> + printf(" expected[2] = %f; result[2] = %f\n",
> + f_ceil_expected[2], f_result[2]);
> + printf(" expected[3] = %f; result[3] = %f\n",
> + f_ceil_expected[3], f_result[3]);
> + }
> +#else
> + abort();
> +#endif
It looks that you can use some macro for different floating point functions
and its check and dumping here, since the basic skeleton are sharable, some
thing like:
#define FLOAT_CHECK(NAME) \
f_result = vec_##NAME(f_src); \
\
if ((f_result[0] != f_##NAME##_expected[0]) || \
(f_result[1] != f_##NAME##_expected[1]) || \
(f_result[2] != f_##NAME##_expected[2]) || \
(f_result[3] != f_##NAME##_expected[3])) { \
if (DEBUG) { \
printf("ERROR: vec_%s (float) expected value does not match\n", #NAME); \
printf(" expected[0] = %f; result[0] = %f\n", f_##NAME##_expected[0], \
f_result[0]); \
printf(" expected[1] = %f; result[1] = %f\n", f_##NAME##_expected[1], \
f_result[1]); \
printf(" expected[2] = %f; result[2] = %f\n", f_##NAME##_expected[2], \
f_result[2]); \
printf(" expected[3] = %f; result[3] = %f\n", f_##NAME##_expected[3], \
f_result[3]); \
} else \
abort(); \
}
...
FLOAT_CHECK(ceil)
FLOAT_CHECK(nearbyint)
...
I hope it can help to make it brief and avoid some copy & paste typos.
But since you already expanded them, it's fine to me if you wanted to keep
the expanded ones. :)
> +
> + /* Floor, float */
> + f_result = vec_floor (f_src);
> +
> + if ((f_result[0] != f_floor_expected[0])
> + || (f_result[1] != f_floor_expected[1])
> + || (f_result[2] != f_floor_expected[2])
> + || (f_result[3] != f_floor_expected[3]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_floor (float) expected value does not match\n");
> + printf(" expected[0] = %f; result[0] = %f\n",
> + f_floor_expected[0], f_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + f_floor_expected[1], f_result[1]);
> + printf(" expected[2] = %f; result[2] = %f\n",
> + f_floor_expected[2], f_result[2]);
> + printf(" expected[3] = %f; result[3] = %f\n",
> + f_floor_expected[3], f_result[3]);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Nearby int, float */
> + f_result = vec_nearbyint (f_src);
> +
> + if ((f_result[0] != f_nearbyint_expected[0])
> + || (f_result[1] != f_nearbyint_expected[1])
> + || (f_result[2] != f_nearbyint_expected[2])
> + || (f_result[3] != f_nearbyint_expected[3]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_nearby (float) expected value does not match\n");
> + printf(" expected[0] = %f; result[0] = %f\n",
> + f_nearbyint_expected[0], f_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + f_nearbyint_expected[1], f_result[1]);
> + printf(" expected[2] = %f; result[2] = %f\n",
> + f_nearbyint_expected[2], f_result[2]);
> + printf(" expected[3] = %f; result[3] = %f\n",
> + f_nearbyint_expected[3], f_result[3]);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Round, float */
> + f_result = vec_rint (f_src);
> +
> + if ((f_result[0] != f_rint_expected[0])
> + || (f_result[1] != f_rint_expected[1])
> + || (f_result[2] != f_rint_expected[2])
> + || (f_result[3] != f_rint_expected[3]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_rint (float) expected value does not match\n");
> + printf(" expected[0] = %f; result[0] = %f\n",
> + f_rint_expected[0], f_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + f_rint_expected[1], f_result[1]);
> + printf(" expected[2] = %f; result[2] = %f\n",
> + f_rint_expected[2], f_result[2]);
> + printf(" expected[3] = %f; result[3] = %f\n",
> + f_rint_expected[3], f_result[3]);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Square, float */
> + f_result = vec_sqrt (vec_abs(f_src));
> +
> + if ((f_result[0] != f_sqrt_expected[0])
> + || (f_result[1] != f_sqrt_expected[1])
> + || (f_result[2] != f_sqrt_expected[2])
> + || (f_result[3] != f_sqrt_expected[3]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_sqrt (float) expected value does not match\n");
> + printf(" expected[0] = %f; result[0] = %f\n",
> + f_sqrt_expected[0], f_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + f_sqrt_expected[1], f_result[1]);
> + printf(" expected[2] = %f; result[2] = %f\n",
> + f_sqrt_expected[2], f_result[2]);
> + printf(" expected[3] = %f; result[3] = %f\n",
> + f_sqrt_expected[3], f_result[3]);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Truncate, float */
> + f_result = vec_trunc (f_src);
> +
> + if ((f_result[0] != f_trunc_expected[0])
> + || (f_result[1] != f_trunc_expected[1])
> + || (f_result[2] != f_trunc_expected[2])
> + || (f_result[3] != f_trunc_expected[3]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_trunc (float) expected value does not match\n");
> + printf(" expected[0] = %f; result[0] = %f\n",
> + f_trunc_expected[0], f_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + f_trunc_expected[1], f_result[1]);
> + printf(" expected[2] = %f; result[2] = %f\n",
> + f_trunc_expected[2], f_result[2]);
> + printf(" expected[3] = %f; result[3] = %f\n",
> + f_trunc_expected[3], f_result[3]);
> + }
> +#else
> + abort();
> +#endif
> +
>
snip ...
> +
> + /* Vector select */
> + d_result = vec_sel (d_src_a, d_src_b, ull_src_c);
> +
> + if ((d_result[0] != d_selectu_expected[0])
> + || (d_result[1] != d_selectu_expected[1]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_msub (double, unsigned) expected value does not match\n");
Copy & paste typo.
> + printf(" expected[0] = %f; result[0] = %f\n",
> + d_selectu_expected[0], d_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + d_selectu_expected[1], d_result[1]);
> + }
> +#else
> + abort();
> +#endif
> +
> + d_result = vec_sel (d_src_a, d_src_b, bll_src_c);
> +
> + if ((d_result[0] != d_selectb_expected[0])
> + || (d_result[1] != d_selectb_expected[1]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_msub (double, bool) expected value does not match\n");
Ditto
> + printf(" expected[0] = %f; result[0] = %f\n",
> + d_selectb_expected[0], d_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + d_selectb_expected[1], d_result[1]);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Vector permute */
> + d_result = vec_perm (d_src_a, d_src_b, uc_src_c);
> +
> + if ((d_result[0] != d_perm_expected[0])
> + || (d_result[1] != d_perm_expected[1]))
> +#if DEBUG
> + {
> + printf("ERROR: vec_perf (unsigned char) expected value does not match\n");
perf -> perm
> + printf(" expected[0] = %f; result[0] = %f\n",
> + d_perm_expected[0], d_result[0]);
> + printf(" expected[1] = %f; result[1] = %f\n",
> + d_perm_expected[1], d_result[1]);
> + }
> +#else
> + abort();
> +#endif
> +
> + return 0;
> +}
> diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c
> new file mode 100644
> index 00000000000..4558918058e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c
> @@ -0,0 +1,429 @@
> +/* { dg-do compile { target lp64 } } */
> +/* { dg-skip-if "" { powerpc*-*-darwin* } } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
> +
> +/* Functional test of the vector compare all builtins. */
> +
> +#include <altivec.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <stdbool.h>
> +
> +#define DEBUG 0
> +
> +void abort (void);
> +
> +int
> +main () {
> + int i;
> + vector float f_src_a = {126.0, 23.0, -338.0, 17.0};
> + vector float f_src_b = {2.00, 23.0, 1.0, 4.0};
> + bool f_result;
> + bool f_all_eq_expected = 0;
> + bool f_all_gt_expected = 0;
> + bool f_all_ge_expected = 0;
> + bool f_all_lt_expected = 0;
> + bool f_all_le_expected = 0;
> + bool f_all_nan_expected = 0;
> + bool f_all_numeric_expected = 1;
> + bool f_any_eq_expected = 1;
> + bool f_any_gt_expected = 1;
> + bool f_any_ge_expected = 1;
> + bool f_any_lt_expected = 1;
> + bool f_any_le_expected = 1;
> + bool f_any_nan_expected = 0;
> + bool f_any_numeric_expected = 1;
> +
> + vector double d_src_a = { 125.44, -338.56};
> + vector double d_src_b = d_src_a;
> + bool d_result;
> + bool d_all_eq_expected = 1;
> + bool d_all_gt_expected = 0;
> + bool d_all_ge_expected = 1;
> + bool d_all_lt_expected = 0;
> + bool d_all_le_expected = 1;
> + bool d_all_nan_expected = 0;
> + bool d_all_numeric_expected = 1;
> + bool d_any_eq_expected = 1;
> + bool d_any_gt_expected = 0;
> + bool d_any_ge_expected = 1;
> + bool d_any_lt_expected = 0;
> + bool d_any_le_expected = 1;
> + bool d_any_nan_expected = 0;
> + bool d_any_numeric_expected = 1;
> +
> + /* Compare all equal, float */
> + f_result = vec_all_eq (f_src_a, f_src_b);
> +
> + if (f_result != f_all_eq_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_all_eq (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n",
> + f_all_eq_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare all greater than, float */
> + f_result = vec_all_gt (f_src_a, f_src_b);
> +
> + if (f_result != f_all_gt_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_all_gt (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n",
> + f_all_gt_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare all greater than or equal, float */
> + f_result = vec_all_ge (f_src_a, f_src_b);
> +
> + if (f_result != f_all_ge_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_all_ge(float) expected value does not match\n");
inconsistent style (missing one space after vec_all_ge).
> + printf(" expected] = %d; result = %d\n", f_all_ge_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare all less than, float */
> + f_result = vec_all_lt (f_src_a, f_src_b);
> +
> + if (f_result != f_all_lt_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_all_lt (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n", f_all_lt_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare all less than or equal, float */
> + f_result = vec_all_le (f_src_a, f_src_b);
> +
> + if (f_result != f_all_le_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_all_le (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n", f_all_le_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* All NaN, float */
> + f_result = vec_all_nan (f_src_a);
> +
> + if (f_result != f_all_nan_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_all_le (float) expected value does not match\n");
copy & paste typo.
> + printf(" expected = %d; result = %d\n", f_all_nan_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* All numeric, float */
> + f_result = vec_all_numeric (f_src_a);
> +
> + if (f_result != f_all_numeric_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_all_numeric (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n", f_all_numeric_expected,
> + f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> +
> + /* Compare any equal, float */
> + f_result = vec_any_eq (f_src_a, f_src_b);
> +
> + if (f_result != f_any_eq_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_any_eq (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n",
> + f_any_eq_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare any greater than, float */
> + f_result = vec_any_gt (f_src_a, f_src_b);
> +
> + if (f_result != f_any_gt_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_any_gt (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n",
> + f_any_gt_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare any greater than or equal, float */
> + f_result = vec_any_ge (f_src_a, f_src_b);
> +
> + if (f_result != f_any_ge_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_any_ge(float) expected value does not match\n");
missing one space.
> + printf(" expected] = %d; result = %d\n", f_any_ge_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare any less than, float */
> + f_result = vec_any_lt (f_src_a, f_src_b);
> +
> + if (f_result != f_any_lt_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_any_lt (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n", f_any_lt_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Compare any less than or equal, float */
> + f_result = vec_any_le (f_src_a, f_src_b);
> +
> + if (f_result != f_any_le_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_any_le (float) expected value does not match\n");
> + printf(" expected = %d; result = %d\n", f_any_le_expected, f_result);
> + }
> +#else
> + abort();
> +#endif
> +
> + /* Any NaN, float */
> + f_result = vec_any_nan (f_src_a);
> +
> + if (f_result != f_any_nan_expected)
> +#if DEBUG
> + {
> + printf("ERROR: vec_any_le (float) expected value does not match\n");
typo, s/vec_any_le/vec_any_nan/
BR,
Kewen
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-19 7:17 ` Kewen.Lin
@ 2023-06-21 22:42 ` Carl Love
2023-06-28 8:35 ` Kewen.Lin
0 siblings, 1 reply; 12+ messages in thread
From: Carl Love @ 2023-06-21 22:42 UTC (permalink / raw)
To: Kewen.Lin; +Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
On Mon, 2023-06-19 at 15:17 +0800, Kewen.Lin wrote:
> Hi Carl,
>
> on 2023/5/31 04:46, Carl Love wrote:
> > GCC maintainers:
> >
> > The following patch takes the tests in vsx-vector-6-p7.h, vsx-
> > vector-
> > 6-p8.h, vsx-vector-6-p9.h and reorganizes them into a series of
> > smaller
> > test files by functionality rather than processor version.
> >
> > The patch has been tested on Power 10 with no regressions.
> >
> > Please let me know if this patch is acceptable for
> > mainline. Thanks.
> >
> > Carl
> >
> > ------------------------------------------
> > rs6000: Update the vsx-vector-6.* tests.
> >
> > The vsx-vector-6.h file is included into the processor specific
> > test files
> > vsx-vector-6.p7.c, vsx-vector-6.p8.c, and vsx-vector-6.p9.c. The
> > .h file
> > contains a large number of vsx vector builtin tests. The processor
> > specific files contain the number of instructions that the tests
> > are
> > expected to generate for that processor. The tests are compile
> > only.
> >
> > The tests are broken up into a seriers of files for related
> > tests. The
> > new tests are runnable tests to verify the builtin argument types
> > and the
>
> But the newly added test cases are all with "dg-do compile", it
> doesn't
> match what you said here.
Ah, yea, that is wrong. Fixed.
>
> > functional correctness of each test rather then verifying the type
> > and
> > number of instructions generated.
>
> It's good to have more coverage with runnable case, but we miss some
> test
> coverages on the expected insn counts which cases p{7,8,9}.c can
> provide
> originally. Unless we can ensure it's already tested somewhere else
> (do
> we? it wasn't stated in this patch), I think we still need those
> checks.
Yea, I was going with a runnable test and didn't include the
instruction counts. Added back in. Rather then doing by processor
version (P8, P9, P10) I was able to do it by BE/LE. The instruction
counts were the same for LE accross processor versions but there are a
few instruction counts that vary with BE and LE.
I did noticed in one of the tests that the compiler computed the
answers at compile time and thus didn't actually generate the builtin
code. After digging a little more I found a few more tests where the
compiler was doing the calculations and just inserting the answers.
So, I moved all of the tests to functions so the compiler would
actually generate the desired builtin code.
>
> > gcc/testsuite/
> > * gcc.target/powerpc/vsx-vector-6-1op.c: New test file.
> > * gcc.target/powerpc/vsx-vector-6-2lop.c: New test file.
> > * gcc.target/powerpc/vsx-vector-6-2op.c: New test file.
> > * gcc.target/powerpc/vsx-vector-6-3op.c: New test file.
> > * gcc.target/powerpc/vsx-vector-6-cmp-all.c: New test file.
> > * gcc.target/powerpc/vsx-vector-6-cmp.c: New test file.
> > * gcc.target/powerpc/vsx-vector-6.h: Remove test file.
> > * gcc.target/powerpc/vsx-vector-6-p7.h: Remove test file.
> > * gcc.target/powerpc/vsx-vector-6-p8.h: Remove test file.
> > * gcc.target/powerpc/vsx-vector-6-p9.h: Remove test file.
> > ---
> > .../powerpc/vsx-vector-6-func-1op.c | 319 +++++++++++++
> > .../powerpc/vsx-vector-6-func-2lop.c | 305 +++++++++++++
> > .../powerpc/vsx-vector-6-func-2op.c | 278 ++++++++++++
> > .../powerpc/vsx-vector-6-func-3op.c | 229 ++++++++++
> > .../powerpc/vsx-vector-6-func-cmp-all.c | 429
> > ++++++++++++++++++
> > .../powerpc/vsx-vector-6-func-cmp.c | 237 ++++++++++
> > .../gcc.target/powerpc/vsx-vector-6.h | 154 -------
> > .../gcc.target/powerpc/vsx-vector-6.p7.c | 43 --
> > .../gcc.target/powerpc/vsx-vector-6.p8.c | 43 --
> > .../gcc.target/powerpc/vsx-vector-6.p9.c | 42 --
> > 10 files changed, 1797 insertions(+), 282 deletions(-)
> > create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
> > func-1op.c
> > create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
> > func-2lop.c
> > create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
> > func-2op.c
> > create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
> > func-3op.c
> > create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
> > func-cmp-all.c
> > create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
> > func-cmp.c
> > delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.h
> > delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-
> > 6.p7.c
> > delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-
> > 6.p8.c
> > delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-
> > 6.p9.c
> >
> > diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-
> > 1op.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
> > new file mode 100644
> > index 00000000000..90a360ea158
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
> > @@ -0,0 +1,319 @@
> > +/* { dg-do compile { target lp64 } } */
> > +/* { dg-skip-if "" { powerpc*-*-darwin* } } */
> > +/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
> > +
> > +/* Functional test of the one operand vector builtins. */
> > +
> > +#include <altivec.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +
> > +#define DEBUG 0
> > +
> > +void abort (void);
> > +
> > +int
> > +main () {
> > + int i;
> > + vector float f_src = { 125.44, 23.04, -338.56, 17.64};
> > + vector float f_result;
> > + vector float f_abs_expected = { 125.44, 23.04, 338.56, 17.64};
> > + vector float f_ceil_expected = { 126.0, 24.0, -338, 18.0};
> > + vector float f_floor_expected = { 125.0, 23.0, -339, 17.0};
> > + vector float f_nearbyint_expected = { 125.0, 23.0, -339, 18.0};
> > + vector float f_rint_expected = { 125.0, 23.0, -339, 18.0};
> > + vector float f_sqrt_expected = { 11.2, 4.8, 18.4, 4.2};
> > + vector float f_trunc_expected = { 125.0, 23.0, -338, 17};
> > +
> > + vector double d_src = { 125.44, -338.56};
> > + vector double d_result;
> > + vector double d_abs_expected = { 125.44, 338.56};
> > + vector double d_ceil_expected = { 126.0, -338.0};
> > + vector double d_floor_expected = { 125.0, -339.0};
> > + vector double d_nearbyint_expected = { 125.0, -339.0};
> > + vector double d_rint_expected = { 125.0, -339.0};
> > + vector double d_sqrt_expected = { 11.2, 18.4};
> > + vector double d_trunc_expected = { 125.0, -338.0};
> > +
> > + /* Abs, float */
> > + f_result = vec_abs (f_src);
> > +
> > + if ((f_result[0] != f_abs_expected[0])
> > + || (f_result[1] != f_abs_expected[1])
> > + || (f_result[2] != f_abs_expected[2])
> > + || (f_result[3] != f_abs_expected[3]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_abs (float) expected value does not
> > match\n");
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + f_abs_expected[0], f_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + f_abs_expected[1], f_result[1]);
> > + printf(" expected[2] = %f; result[2] = %f\n",
> > + f_abs_expected[2], f_result[2]);
> > + printf(" expected[3] = %f; result[3] = %f\n",
> > + f_abs_expected[3], f_result[3]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Ceiling, float */
> > + f_result = vec_ceil (f_src);
> > +
> > + if ((f_result[0] != f_ceil_expected[0])
> > + || (f_result[1] != f_ceil_expected[1])
> > + || (f_result[2] != f_ceil_expected[2])
> > + || (f_result[3] != f_ceil_expected[3]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_ceil (float) expected value does not
> > match\n");
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + f_ceil_expected[0], f_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + f_ceil_expected[1], f_result[1]);
> > + printf(" expected[2] = %f; result[2] = %f\n",
> > + f_ceil_expected[2], f_result[2]);
> > + printf(" expected[3] = %f; result[3] = %f\n",
> > + f_ceil_expected[3], f_result[3]);
> > + }
> > +#else
> > + abort();
> > +#endif
>
> It looks that you can use some macro for different floating point
> functions
> and its check and dumping here, since the basic skeleton are
> sharable, some
> thing like:
>
> #define
> FLOAT_CHECK(NAME)
> \
> f_result =
> vec_##NAME(f_src); \
>
> \
> if ((f_result[0] != f_##NAME##_expected[0])
> || \
> (f_result[1] != f_##NAME##_expected[1])
> || \
> (f_result[2] != f_##NAME##_expected[2])
> || \
> (f_result[3] != f_##NAME##_expected[3]))
> { \
> if (DEBUG)
> { \
> printf("ERROR: vec_%s (float) expected value does not match\n",
> #NAME); \
> printf(" expected[0] = %f; result[0] = %f\n",
> f_##NAME##_expected[0], \
> f_result[0]);
> \
> printf(" expected[1] = %f; result[1] = %f\n",
> f_##NAME##_expected[1], \
> f_result[1]);
> \
> printf(" expected[2] = %f; result[2] = %f\n",
> f_##NAME##_expected[2], \
> f_result[2]);
> \
> printf(" expected[3] = %f; result[3] = %f\n",
> f_##NAME##_expected[3], \
> f_result[3]);
> \
> }
> else
> \
> abort();
> \
> }
>
> ...
> FLOAT_CHECK(ceil)
> FLOAT_CHECK(nearbyint)
> ...
>
> I hope it can help to make it brief and avoid some copy & paste
> typos.
> But since you already expanded them, it's fine to me if you wanted to
> keep
> the expanded ones. :)
Generally, I am not a big fan of large code macros. But in this case
it is probably a good idea given the repetitive code. When I wrote the
test cases, I had to put comments in to identify were each test started
as it gets lost in the code. Use of a macro makes it much easier to
see what cases are being tested.
I changed to using macros for the float and double testing across all
of the tests. There were a few tests where this just one test of that
"type" so I didn't bother doing it with a macro.
>
> > +
> > + /* Floor, float */
> > + f_result = vec_floor (f_src);
> > +
> > + if ((f_result[0] != f_floor_expected[0])
> > + || (f_result[1] != f_floor_expected[1])
> > + || (f_result[2] != f_floor_expected[2])
> > + || (f_result[3] != f_floor_expected[3]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_floor (float) expected value does not
> > match\n");
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + f_floor_expected[0], f_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + f_floor_expected[1], f_result[1]);
> > + printf(" expected[2] = %f; result[2] = %f\n",
> > + f_floor_expected[2], f_result[2]);
> > + printf(" expected[3] = %f; result[3] = %f\n",
> > + f_floor_expected[3], f_result[3]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Nearby int, float */
> > + f_result = vec_nearbyint (f_src);
> > +
> > + if ((f_result[0] != f_nearbyint_expected[0])
> > + || (f_result[1] != f_nearbyint_expected[1])
> > + || (f_result[2] != f_nearbyint_expected[2])
> > + || (f_result[3] != f_nearbyint_expected[3]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_nearby (float) expected value does not
> > match\n");
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + f_nearbyint_expected[0], f_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + f_nearbyint_expected[1], f_result[1]);
> > + printf(" expected[2] = %f; result[2] = %f\n",
> > + f_nearbyint_expected[2], f_result[2]);
> > + printf(" expected[3] = %f; result[3] = %f\n",
> > + f_nearbyint_expected[3], f_result[3]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Round, float */
> > + f_result = vec_rint (f_src);
> > +
> > + if ((f_result[0] != f_rint_expected[0])
> > + || (f_result[1] != f_rint_expected[1])
> > + || (f_result[2] != f_rint_expected[2])
> > + || (f_result[3] != f_rint_expected[3]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_rint (float) expected value does not
> > match\n");
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + f_rint_expected[0], f_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + f_rint_expected[1], f_result[1]);
> > + printf(" expected[2] = %f; result[2] = %f\n",
> > + f_rint_expected[2], f_result[2]);
> > + printf(" expected[3] = %f; result[3] = %f\n",
> > + f_rint_expected[3], f_result[3]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Square, float */
> > + f_result = vec_sqrt (vec_abs(f_src));
> > +
> > + if ((f_result[0] != f_sqrt_expected[0])
> > + || (f_result[1] != f_sqrt_expected[1])
> > + || (f_result[2] != f_sqrt_expected[2])
> > + || (f_result[3] != f_sqrt_expected[3]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_sqrt (float) expected value does not
> > match\n");
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + f_sqrt_expected[0], f_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + f_sqrt_expected[1], f_result[1]);
> > + printf(" expected[2] = %f; result[2] = %f\n",
> > + f_sqrt_expected[2], f_result[2]);
> > + printf(" expected[3] = %f; result[3] = %f\n",
> > + f_sqrt_expected[3], f_result[3]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Truncate, float */
> > + f_result = vec_trunc (f_src);
> > +
> > + if ((f_result[0] != f_trunc_expected[0])
> > + || (f_result[1] != f_trunc_expected[1])
> > + || (f_result[2] != f_trunc_expected[2])
> > + || (f_result[3] != f_trunc_expected[3]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_trunc (float) expected value does not
> > match\n");
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + f_trunc_expected[0], f_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + f_trunc_expected[1], f_result[1]);
> > + printf(" expected[2] = %f; result[2] = %f\n",
> > + f_trunc_expected[2], f_result[2]);
> > + printf(" expected[3] = %f; result[3] = %f\n",
> > + f_trunc_expected[3], f_result[3]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> >
>
> snip ...
>
> > +
> > + /* Vector select */
> > + d_result = vec_sel (d_src_a, d_src_b, ull_src_c);
> > +
> > + if ((d_result[0] != d_selectu_expected[0])
> > + || (d_result[1] != d_selectu_expected[1]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_msub (double, unsigned) expected value
> > does not match\n");
>
> Copy & paste typo.
Fixed that bug. The vector select test are still inline code as there
is only one of that type so a macro would only have one use.
>
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + d_selectu_expected[0], d_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + d_selectu_expected[1], d_result[1]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + d_result = vec_sel (d_src_a, d_src_b, bll_src_c);
> > +
> > + if ((d_result[0] != d_selectb_expected[0])
> > + || (d_result[1] != d_selectb_expected[1]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_msub (double, bool) expected value does
> > not match\n");
>
> Ditto
>
Ditto above comment.
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + d_selectb_expected[0], d_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + d_selectb_expected[1], d_result[1]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Vector permute */
> > + d_result = vec_perm (d_src_a, d_src_b, uc_src_c);
> > +
> > + if ((d_result[0] != d_perm_expected[0])
> > + || (d_result[1] != d_perm_expected[1]))
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_perf (unsigned char) expected value does
> > not match\n");
>
> perf -> perm
>
> > + printf(" expected[0] = %f; result[0] = %f\n",
> > + d_perm_expected[0], d_result[0]);
> > + printf(" expected[1] = %f; result[1] = %f\n",
> > + d_perm_expected[1], d_result[1]);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + return 0;
> > +}
> > diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-
> > cmp-all.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-
> > all.c
> > new file mode 100644
> > index 00000000000..4558918058e
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-cmp-all.c
> > @@ -0,0 +1,429 @@
> > +/* { dg-do compile { target lp64 } } */
> > +/* { dg-skip-if "" { powerpc*-*-darwin* } } */
> > +/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
> > +
> > +/* Functional test of the vector compare all builtins. */
> > +
> > +#include <altivec.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <stdbool.h>
> > +
> > +#define DEBUG 0
> > +
> > +void abort (void);
> > +
> > +int
> > +main () {
> > + int i;
> > + vector float f_src_a = {126.0, 23.0, -338.0, 17.0};
> > + vector float f_src_b = {2.00, 23.0, 1.0, 4.0};
> > + bool f_result;
> > + bool f_all_eq_expected = 0;
> > + bool f_all_gt_expected = 0;
> > + bool f_all_ge_expected = 0;
> > + bool f_all_lt_expected = 0;
> > + bool f_all_le_expected = 0;
> > + bool f_all_nan_expected = 0;
> > + bool f_all_numeric_expected = 1;
> > + bool f_any_eq_expected = 1;
> > + bool f_any_gt_expected = 1;
> > + bool f_any_ge_expected = 1;
> > + bool f_any_lt_expected = 1;
> > + bool f_any_le_expected = 1;
> > + bool f_any_nan_expected = 0;
> > + bool f_any_numeric_expected = 1;
> > +
> > + vector double d_src_a = { 125.44, -338.56};
> > + vector double d_src_b = d_src_a;
> > + bool d_result;
> > + bool d_all_eq_expected = 1;
> > + bool d_all_gt_expected = 0;
> > + bool d_all_ge_expected = 1;
> > + bool d_all_lt_expected = 0;
> > + bool d_all_le_expected = 1;
> > + bool d_all_nan_expected = 0;
> > + bool d_all_numeric_expected = 1;
> > + bool d_any_eq_expected = 1;
> > + bool d_any_gt_expected = 0;
> > + bool d_any_ge_expected = 1;
> > + bool d_any_lt_expected = 0;
> > + bool d_any_le_expected = 1;
> > + bool d_any_nan_expected = 0;
> > + bool d_any_numeric_expected = 1;
> > +
> > + /* Compare all equal, float */
> > + f_result = vec_all_eq (f_src_a, f_src_b);
> > +
> > + if (f_result != f_all_eq_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_all_eq (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n",
> > + f_all_eq_expected, f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare all greater than, float */
> > + f_result = vec_all_gt (f_src_a, f_src_b);
> > +
> > + if (f_result != f_all_gt_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_all_gt (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n",
> > + f_all_gt_expected, f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare all greater than or equal, float */
> > + f_result = vec_all_ge (f_src_a, f_src_b);
> > +
> > + if (f_result != f_all_ge_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_all_ge(float) expected value does not
> > match\n");
>
> inconsistent style (missing one space after vec_all_ge).
Eliminated via the use of a macro.
>
> > + printf(" expected] = %d; result = %d\n",
> > f_all_ge_expected, f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare all less than, float */
> > + f_result = vec_all_lt (f_src_a, f_src_b);
> > +
> > + if (f_result != f_all_lt_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_all_lt (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n", f_all_lt_expected,
> > f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare all less than or equal, float */
> > + f_result = vec_all_le (f_src_a, f_src_b);
> > +
> > + if (f_result != f_all_le_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_all_le (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n", f_all_le_expected,
> > f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* All NaN, float */
> > + f_result = vec_all_nan (f_src_a);
> > +
> > + if (f_result != f_all_nan_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_all_le (float) expected value does not
> > match\n");
>
> copy & paste typo.
>
Using macro to generate this test now. So typo should be gone.
> > + printf(" expected = %d; result = %d\n",
> > f_all_nan_expected, f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* All numeric, float */
> > + f_result = vec_all_numeric (f_src_a);
> > +
> > + if (f_result != f_all_numeric_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_all_numeric (float) expected value does
> > not match\n");
> > + printf(" expected = %d; result = %d\n",
> > f_all_numeric_expected,
> > + f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > +
> > + /* Compare any equal, float */
> > + f_result = vec_any_eq (f_src_a, f_src_b);
> > +
> > + if (f_result != f_any_eq_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_any_eq (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n",
> > + f_any_eq_expected, f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare any greater than, float */
> > + f_result = vec_any_gt (f_src_a, f_src_b);
> > +
> > + if (f_result != f_any_gt_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_any_gt (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n",
> > + f_any_gt_expected, f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare any greater than or equal, float */
> > + f_result = vec_any_ge (f_src_a, f_src_b);
> > +
> > + if (f_result != f_any_ge_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_any_ge(float) expected value does not
> > match\n");
>
> missing one space.
Using macro now.
>
> > + printf(" expected] = %d; result = %d\n",
> > f_any_ge_expected, f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare any less than, float */
> > + f_result = vec_any_lt (f_src_a, f_src_b);
> > +
> > + if (f_result != f_any_lt_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_any_lt (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n", f_any_lt_expected,
> > f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Compare any less than or equal, float */
> > + f_result = vec_any_le (f_src_a, f_src_b);
> > +
> > + if (f_result != f_any_le_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_any_le (float) expected value does not
> > match\n");
> > + printf(" expected = %d; result = %d\n", f_any_le_expected,
> > f_result);
> > + }
> > +#else
> > + abort();
> > +#endif
> > +
> > + /* Any NaN, float */
> > + f_result = vec_any_nan (f_src_a);
> > +
> > + if (f_result != f_any_nan_expected)
> > +#if DEBUG
> > + {
> > + printf("ERROR: vec_any_le (float) expected value does not
> > match\n");
>
> typo, s/vec_any_le/vec_any_nan/
Using macro now.
Carl
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-21 22:42 ` Carl Love
@ 2023-06-28 8:35 ` Kewen.Lin
2023-06-29 21:36 ` Carl Love
0 siblings, 1 reply; 12+ messages in thread
From: Kewen.Lin @ 2023-06-28 8:35 UTC (permalink / raw)
To: Carl Love; +Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Hi Carl,
on 2023/6/22 06:42, Carl Love wrote:
> On Mon, 2023-06-19 at 15:17 +0800, Kewen.Lin wrote:
>> Hi Carl,
>>
>> on 2023/5/31 04:46, Carl Love wrote:
>>> GCC maintainers:
>>>
>>> The following patch takes the tests in vsx-vector-6-p7.h, vsx-
>>> vector-
>>> 6-p8.h, vsx-vector-6-p9.h and reorganizes them into a series of
>>> smaller
>>> test files by functionality rather than processor version.
>>>
>>> The patch has been tested on Power 10 with no regressions.
>>>
>>> Please let me know if this patch is acceptable for
>>> mainline. Thanks.
>>>
>>> Carl
>>>
>>> ------------------------------------------
>>> rs6000: Update the vsx-vector-6.* tests.
>>>
>>> The vsx-vector-6.h file is included into the processor specific
>>> test files
>>> vsx-vector-6.p7.c, vsx-vector-6.p8.c, and vsx-vector-6.p9.c. The
>>> .h file
>>> contains a large number of vsx vector builtin tests. The processor
>>> specific files contain the number of instructions that the tests
>>> are
>>> expected to generate for that processor. The tests are compile
>>> only.
>>>
>>> The tests are broken up into a seriers of files for related
>>> tests. The
>>> new tests are runnable tests to verify the builtin argument types
>>> and the
>>
>> But the newly added test cases are all with "dg-do compile", it
>> doesn't
>> match what you said here.
>
> Ah, yea, that is wrong. Fixed.
>
>>
>>> functional correctness of each test rather then verifying the type
>>> and
>>> number of instructions generated.
>>
>> It's good to have more coverage with runnable case, but we miss some
>> test
>> coverages on the expected insn counts which cases p{7,8,9}.c can
>> provide
>> originally. Unless we can ensure it's already tested somewhere else
>> (do
>> we? it wasn't stated in this patch), I think we still need those
>> checks.
>
> Yea, I was going with a runnable test and didn't include the
> instruction counts. Added back in. Rather then doing by processor
> version (P8, P9, P10) I was able to do it by BE/LE. The instruction
> counts were the same for LE accross processor versions but there are a
> few instruction counts that vary with BE and LE.
But the original test case only checks for cpu-types (processor version)
but not for endianness, it means for the bif usages, there should not be
different for endianness. Why does this changes with your new test case?
Could you have a further look and make it consistent with some adjustment
if possible? As we know, checking insn counts sometimes are fragile, so
I think we should try our best to make it as robust as possible in the
first place.
Besides, the original case also have some differences between p7/p8 and
p9.
>
> I did noticed in one of the tests that the compiler computed the
> answers at compile time and thus didn't actually generate the builtin
> code. After digging a little more I found a few more tests where the
> compiler was doing the calculations and just inserting the answers.
I'd suggest you also adding function attribute __attribute__((noipa))
to those functions avoiding the possible inlining.
>
> So, I moved all of the tests to functions so the compiler would
> actually generate the desired builtin code.
>
>>
>>> gcc/testsuite/
>>> * gcc.target/powerpc/vsx-vector-6-1op.c: New test file.
>>> * gcc.target/powerpc/vsx-vector-6-2lop.c: New test file.
>>> * gcc.target/powerpc/vsx-vector-6-2op.c: New test file.
>>> * gcc.target/powerpc/vsx-vector-6-3op.c: New test file.
>>> * gcc.target/powerpc/vsx-vector-6-cmp-all.c: New test file.
>>> * gcc.target/powerpc/vsx-vector-6-cmp.c: New test file.
>>> * gcc.target/powerpc/vsx-vector-6.h: Remove test file.
>>> * gcc.target/powerpc/vsx-vector-6-p7.h: Remove test file.
>>> * gcc.target/powerpc/vsx-vector-6-p8.h: Remove test file.
>>> * gcc.target/powerpc/vsx-vector-6-p9.h: Remove test file.
>>> ---
>>> .../powerpc/vsx-vector-6-func-1op.c | 319 +++++++++++++
>>> .../powerpc/vsx-vector-6-func-2lop.c | 305 +++++++++++++
>>> .../powerpc/vsx-vector-6-func-2op.c | 278 ++++++++++++
>>> .../powerpc/vsx-vector-6-func-3op.c | 229 ++++++++++
>>> .../powerpc/vsx-vector-6-func-cmp-all.c | 429
>>> ++++++++++++++++++
>>> .../powerpc/vsx-vector-6-func-cmp.c | 237 ++++++++++
>>> .../gcc.target/powerpc/vsx-vector-6.h | 154 -------
>>> .../gcc.target/powerpc/vsx-vector-6.p7.c | 43 --
>>> .../gcc.target/powerpc/vsx-vector-6.p8.c | 43 --
>>> .../gcc.target/powerpc/vsx-vector-6.p9.c | 42 --
>>> 10 files changed, 1797 insertions(+), 282 deletions(-)
>>> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
>>> func-1op.c
>>> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
>>> func-2lop.c
>>> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
>>> func-2op.c
>>> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
>>> func-3op.c
>>> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
>>> func-cmp-all.c
>>> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6-
>>> func-cmp.c
>>> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-6.h
>>> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-
>>> 6.p7.c
>>> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-
>>> 6.p8.c
>>> delete mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-vector-
>>> 6.p9.c
>>>
>>> diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-
>>> 1op.c b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
>>> new file mode 100644
>>> index 00000000000..90a360ea158
>>> --- /dev/null
>>> +++ b/gcc/testsuite/gcc.target/powerpc/vsx-vector-6-func-1op.c
>>> @@ -0,0 +1,319 @@
>>> +/* { dg-do compile { target lp64 } } */
>>> +/* { dg-skip-if "" { powerpc*-*-darwin* } } */
>>> +/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
>>> +
>>> +/* Functional test of the one operand vector builtins. */
>>> +
>>> +#include <altivec.h>
>>> +#include <stdio.h>
>>> +#include <stdlib.h>
>>> +
>>> +#define DEBUG 0
>>> +
>>> +void abort (void);
>>> +
>>> +int
>>> +main () {
>>> + int i;
>>> + vector float f_src = { 125.44, 23.04, -338.56, 17.64};
>>> + vector float f_result;
>>> + vector float f_abs_expected = { 125.44, 23.04, 338.56, 17.64};
>>> + vector float f_ceil_expected = { 126.0, 24.0, -338, 18.0};
>>> + vector float f_floor_expected = { 125.0, 23.0, -339, 17.0};
>>> + vector float f_nearbyint_expected = { 125.0, 23.0, -339, 18.0};
>>> + vector float f_rint_expected = { 125.0, 23.0, -339, 18.0};
>>> + vector float f_sqrt_expected = { 11.2, 4.8, 18.4, 4.2};
>>> + vector float f_trunc_expected = { 125.0, 23.0, -338, 17};
>>> +
>>> + vector double d_src = { 125.44, -338.56};
>>> + vector double d_result;
>>> + vector double d_abs_expected = { 125.44, 338.56};
>>> + vector double d_ceil_expected = { 126.0, -338.0};
>>> + vector double d_floor_expected = { 125.0, -339.0};
>>> + vector double d_nearbyint_expected = { 125.0, -339.0};
>>> + vector double d_rint_expected = { 125.0, -339.0};
>>> + vector double d_sqrt_expected = { 11.2, 18.4};
>>> + vector double d_trunc_expected = { 125.0, -338.0};
>>> +
>>> + /* Abs, float */
>>> + f_result = vec_abs (f_src);
>>> +
>>> + if ((f_result[0] != f_abs_expected[0])
>>> + || (f_result[1] != f_abs_expected[1])
>>> + || (f_result[2] != f_abs_expected[2])
>>> + || (f_result[3] != f_abs_expected[3]))
>>> +#if DEBUG
>>> + {
>>> + printf("ERROR: vec_abs (float) expected value does not
>>> match\n");
>>> + printf(" expected[0] = %f; result[0] = %f\n",
>>> + f_abs_expected[0], f_result[0]);
>>> + printf(" expected[1] = %f; result[1] = %f\n",
>>> + f_abs_expected[1], f_result[1]);
>>> + printf(" expected[2] = %f; result[2] = %f\n",
>>> + f_abs_expected[2], f_result[2]);
>>> + printf(" expected[3] = %f; result[3] = %f\n",
>>> + f_abs_expected[3], f_result[3]);
>>> + }
>>> +#else
>>> + abort();
>>> +#endif
>>> +
>>> + /* Ceiling, float */
>>> + f_result = vec_ceil (f_src);
>>> +
>>> + if ((f_result[0] != f_ceil_expected[0])
>>> + || (f_result[1] != f_ceil_expected[1])
>>> + || (f_result[2] != f_ceil_expected[2])
>>> + || (f_result[3] != f_ceil_expected[3]))
>>> +#if DEBUG
>>> + {
>>> + printf("ERROR: vec_ceil (float) expected value does not
>>> match\n");
>>> + printf(" expected[0] = %f; result[0] = %f\n",
>>> + f_ceil_expected[0], f_result[0]);
>>> + printf(" expected[1] = %f; result[1] = %f\n",
>>> + f_ceil_expected[1], f_result[1]);
>>> + printf(" expected[2] = %f; result[2] = %f\n",
>>> + f_ceil_expected[2], f_result[2]);
>>> + printf(" expected[3] = %f; result[3] = %f\n",
>>> + f_ceil_expected[3], f_result[3]);
>>> + }
>>> +#else
>>> + abort();
>>> +#endif
>>
>> It looks that you can use some macro for different floating point
>> functions
>> and its check and dumping here, since the basic skeleton are
>> sharable, some
>> thing like:
>>
>> #define
>> FLOAT_CHECK(NAME)
>> \
>> f_result =
>> vec_##NAME(f_src); \
>>
>> \
>> if ((f_result[0] != f_##NAME##_expected[0])
>> || \
>> (f_result[1] != f_##NAME##_expected[1])
>> || \
>> (f_result[2] != f_##NAME##_expected[2])
>> || \
>> (f_result[3] != f_##NAME##_expected[3]))
>> { \
>> if (DEBUG)
>> { \
>> printf("ERROR: vec_%s (float) expected value does not match\n",
>> #NAME); \
>> printf(" expected[0] = %f; result[0] = %f\n",
>> f_##NAME##_expected[0], \
>> f_result[0]);
>> \
>> printf(" expected[1] = %f; result[1] = %f\n",
>> f_##NAME##_expected[1], \
>> f_result[1]);
>> \
>> printf(" expected[2] = %f; result[2] = %f\n",
>> f_##NAME##_expected[2], \
>> f_result[2]);
>> \
>> printf(" expected[3] = %f; result[3] = %f\n",
>> f_##NAME##_expected[3], \
>> f_result[3]);
>> \
>> }
>> else
>> \
>> abort();
>> \
>> }
>>
>> ...
>> FLOAT_CHECK(ceil)
>> FLOAT_CHECK(nearbyint)
>> ...
>>
>> I hope it can help to make it brief and avoid some copy & paste
>> typos.
>> But since you already expanded them, it's fine to me if you wanted to
>> keep
>> the expanded ones. :)
>
> Generally, I am not a big fan of large code macros. But in this case
> it is probably a good idea given the repetitive code. When I wrote the
> test cases, I had to put comments in to identify were each test started
> as it gets lost in the code. Use of a macro makes it much easier to
> see what cases are being tested.
Yeah, it should help to avoid those typos. Thanks for updating.
BR,
Kewen
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-28 8:35 ` Kewen.Lin
@ 2023-06-29 21:36 ` Carl Love
2023-06-30 3:37 ` Kewen.Lin
0 siblings, 1 reply; 12+ messages in thread
From: Carl Love @ 2023-06-29 21:36 UTC (permalink / raw)
To: Kewen.Lin; +Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Kewen:
On Wed, 2023-06-28 at 16:35 +0800, Kewen.Lin wrote:
> > Yea, I was going with a runnable test and didn't include the
> > instruction counts. Added back in. Rather then doing by processor
> > version (P8, P9, P10) I was able to do it by BE/LE. The
> > instruction
> > counts were the same for LE accross processor versions but there
> > are a
> > few instruction counts that vary with BE and LE.
>
> But the original test case only checks for cpu-types (processor
> version)
> but not for endianness, it means for the bif usages, there should not
> be
> different for endianness. Why does this changes with your new test
> case?
> Could you have a further look and make it consistent with some
> adjustment
> if possible? As we know, checking insn counts sometimes are fragile,
> so
> I think we should try our best to make it as robust as possible in
> the
> first place.
>
> Besides, the original case also have some differences between p7/p8
> and
> p9.
>
There are differences on P8 LE versus BE. I did a diff between the P8
and P9 tests:
diff vsx-vector-6.p8.c vsx-vector-6.p9.c
3,4c3,4
< /* { dg-require-effective-target powerpc_p8vector_ok } */
< /* { dg-options "-O2 -mdejagnu-cpu=power8" } */
---
> /* { dg-require-effective-target powerpc_p9vector_ok } */
> /* { dg-options "-O2 -mdejagnu-cpu=power9" } */
12c12
< /* { dg-final { scan-assembler-times {\mvperm\M} 1 } } */
---
> /* { dg-final { scan-assembler-times {\m(?:v|xx)permr?\M} 1 } } */
23d22
< /* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
37c36
< /* { dg-final { scan-assembler-times {\mxvsubdp\M} 1 } } */
---
> /* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
So we can see the vperm, vpermr, xxpermr, xvmsubadp, xvmsubmdp,
xvsubdp, xvmsubadp, xvmsubmdp instruction count checks are different
between the two architectures. I then wrote a script to compile the
CPU specific test on Power 8, Power 9 and Power 10 architectures and
then grep for the above list of instructions. If I run the scrip on P8
BE and LE I get
Power 8 BE Power 8 LE Power 9 LE Power 9 BE Power 10 LE*
(makalu-lp1) (genoa) (marlin) (nilram) (ltcd97-lp3)
instruction count count count count count
vperm 1 1 0 0 0
vpermr 0 0 0 0 0
xxpermr 0 0 1 0 1
xvmsubadp 1 0 1 1 1
xvmsubmdp 0 1 0 0 0
xvsubdp 1 1 1 1 1
From the diff we see
{ dg-final {scan-assembler-times {\mxvmsub[am]dp\M} 1 } }
This test picks up the correct subtraction instruction for LE versus BE
so this "masks" the LE/BE difference. I changed the check in vsx-
vector-6-func-3op.c to match. This eliminates the LE and BE checks and
reduces the number of specific checks.
In vsx-vector-6-func-3op.c The new test checks the counts for
xxpermdi, which the original test does not check. The check for
xxpermdi are not needed. They are not directly related to the builtin
tests. I removed them.
Looking at the LE/BE checks in the other test file vsx-vector-6-func-
2op.c, instructions xvmaxsp, xvminsp and xvmaxdp were not checked in
the original test. The functions where these instructions are used get
inlined. On LE, the binary instructions show up in the inlined code as
well as what appears to be the binary for the original, non-inlined
function. Best I can see, the binary for the original function is dead
code. I don't see any calls to it. Seems like it shouldn't be there
as it would make the binary smaller. On BE, I don't see the binary for
the original non-inlined function.
I had played with putting -Wno-inline on the command line but that
didn't seem to make any difference. However, you suggestion of
__attribute__ ((noipa)) does prevent the inlining and we don't get the
second copy of the instructions showing up. The inlining eliminated the
LE/BE differences for xvmaxsp, xvminsp and xvmaxdp.
The instruction count test for xxlor in vsx-vector-6-func-2lop.c
differs on LE and BE vsx-vector-6-func-2op.c. I believe the
instruction is used with loads to reorder the data. I don't see anyway
to get around the extra xxlor instructions and verify the vec_or
builtin test generates the instruction.
I was able to eliminate all of the LE/BE qualifiers in the instruction
counts with the exception of xxlor. By using the same checks that look
for multiple versions of xvmsumb*, as was done in the original test, we
can also eliminate LE/BE specific tests and account for different
instructions across CPU versions. We could go back to checking for
specific instructions being generated on Power 8, Power 9, Power 10 if
you prefer not using checks that cover multiple flavors of a given
instruction across different CPU types.
FYI, I eliminated the function call to do the various tests. Instead,
I modified the macro to generate a function call to do the test and
check the results.
Carl
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-29 21:36 ` Carl Love
@ 2023-06-30 3:37 ` Kewen.Lin
2023-06-30 22:20 ` Carl Love
0 siblings, 1 reply; 12+ messages in thread
From: Kewen.Lin @ 2023-06-30 3:37 UTC (permalink / raw)
To: Carl Love; +Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Hi Carl,
on 2023/6/30 05:36, Carl Love wrote:
> Kewen:
>
> On Wed, 2023-06-28 at 16:35 +0800, Kewen.Lin wrote:
>>> Yea, I was going with a runnable test and didn't include the
>>> instruction counts. Added back in. Rather then doing by processor
>>> version (P8, P9, P10) I was able to do it by BE/LE. The
>>> instruction
>>> counts were the same for LE accross processor versions but there
>>> are a
>>> few instruction counts that vary with BE and LE.
>>
>> But the original test case only checks for cpu-types (processor
>> version)
>> but not for endianness, it means for the bif usages, there should not
>> be
>> different for endianness. Why does this changes with your new test
>> case?
>> Could you have a further look and make it consistent with some
>> adjustment
>> if possible? As we know, checking insn counts sometimes are fragile,
>> so
>> I think we should try our best to make it as robust as possible in
>> the
>> first place.
>>
>> Besides, the original case also have some differences between p7/p8
>> and
>> p9.
>>
>
> There are differences on P8 LE versus BE. I did a diff between the P8
> and P9 tests:
>
> diff vsx-vector-6.p8.c vsx-vector-6.p9.c
> 3,4c3,4
> < /* { dg-require-effective-target powerpc_p8vector_ok } */
> < /* { dg-options "-O2 -mdejagnu-cpu=power8" } */
> ---
>> /* { dg-require-effective-target powerpc_p9vector_ok } */
>> /* { dg-options "-O2 -mdejagnu-cpu=power9" } */
> 12c12
> < /* { dg-final { scan-assembler-times {\mvperm\M} 1 } } */
> ---
>> /* { dg-final { scan-assembler-times {\m(?:v|xx)permr?\M} 1 } } */
> 23d22
> < /* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
> 37c36
> < /* { dg-final { scan-assembler-times {\mxvsubdp\M} 1 } } */
> ---
>> /* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
>
> So we can see the vperm, vpermr, xxpermr, xvmsubadp, xvmsubmdp,
> xvsubdp, xvmsubadp, xvmsubmdp instruction count checks are different
> between the two architectures. I then wrote a script to compile the
> CPU specific test on Power 8, Power 9 and Power 10 architectures and
> then grep for the above list of instructions. If I run the scrip on P8
> BE and LE I get>
>
> Power 8 BE Power 8 LE Power 9 LE Power 9 BE Power 10 LE*
> (makalu-lp1) (genoa) (marlin) (nilram) (ltcd97-lp3)
> instruction count count count count count
> vperm 1 1 0 0 0
> vpermr 0 0 0 0 0
> xxpermr 0 0 1 0 1
> xvmsubadp 1 0 1 1 1
> xvmsubmdp 0 1 0 0 0
> xvsubdp 1 1 1 1 1
>
Thanks for looking into this and making this statistics.
Is there a typo for column nilram? Otherwise, the below insn check
/* { dg-final { scan-assembler-times {\m(?:v|xx)permr?\M} 1 } } */
would fail there.
>
> From the diff we see
>
> { dg-final {scan-assembler-times {\mxvmsub[am]dp\M} 1 } }
>
> This test picks up the correct subtraction instruction for LE versus BE
> so this "masks" the LE/BE difference. I changed the check in vsx-
> vector-6-func-3op.c to match. This eliminates the LE and BE checks and
> reduces the number of specific checks.
OK, nice.
>
> In vsx-vector-6-func-3op.c The new test checks the counts for
> xxpermdi, which the original test does not check. The check for
> xxpermdi are not needed. They are not directly related to the builtin
> tests. I removed them.
OK.
>
> Looking at the LE/BE checks in the other test file vsx-vector-6-func-
> 2op.c, instructions xvmaxsp, xvminsp and xvmaxdp were not checked in
> the original test. The functions where these instructions are used get
> inlined. On LE, the binary instructions show up in the inlined code as
> well as what appears to be the binary for the original, non-inlined
> function. Best I can see, the binary for the original function is dead
> code. I don't see any calls to it. Seems like it shouldn't be there
> as it would make the binary smaller. On BE, I don't see the binary for
> the original non-inlined function.
>
> I had played with putting -Wno-inline on the command line but that
> didn't seem to make any difference. However, you suggestion of
> __attribute__ ((noipa)) does prevent the inlining and we don't get the
> second copy of the instructions showing up. The inlining eliminated the
> LE/BE differences for xvmaxsp, xvminsp and xvmaxdp.
-Winline is a option for warning: "Warn if a function that is declared
as inline cannot be inlined.", I think what you wanted is -fno-inline,
and it's good to know noipa helps here.
>
> The instruction count test for xxlor in vsx-vector-6-func-2lop.c
> differs on LE and BE vsx-vector-6-func-2op.c. I believe the
> instruction is used with loads to reorder the data. I don't see anyway
> to get around the extra xxlor instructions and verify the vec_or
> builtin test generates the instruction.
>
OK, I'm still curious how the loads cause the difference.
> I was able to eliminate all of the LE/BE qualifiers in the instruction
> counts with the exception of xxlor. By using the same checks that look
> for multiple versions of xvmsumb*, as was done in the original test, we
> can also eliminate LE/BE specific tests and account for different
> instructions across CPU versions. We could go back to checking for
> specific instructions being generated on Power 8, Power 9, Power 10 if
> you prefer not using checks that cover multiple flavors of a given
> instruction across different CPU types.
>
> FYI, I eliminated the function call to do the various tests. Instead,
> I modified the macro to generate a function call to do the test and
> check the results.
Got it, I'll review the latest revision soon, thanks.
BR,
Kewen
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-30 3:37 ` Kewen.Lin
@ 2023-06-30 22:20 ` Carl Love
2023-06-30 23:50 ` Carl Love
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: Carl Love @ 2023-06-30 22:20 UTC (permalink / raw)
To: Kewen.Lin, cel
Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Kewen:
On Fri, 2023-06-30 at 11:37 +0800, Kewen.Lin wrote:
> Hi Carl,
>
> on 2023/6/30 05:36, Carl Love wrote:
> > Kewen:
> >
> > On Wed, 2023-06-28 at 16:35 +0800, Kewen.Lin wrote:
> > > > Yea, I was going with a runnable test and didn't include the
> > > > instruction counts. Added back in. Rather then doing by
> > > > processor
> > > > version (P8, P9, P10) I was able to do it by BE/LE. The
> > > > instruction
> > > > counts were the same for LE accross processor versions but
> > > > there
> > > > are a
> > > > few instruction counts that vary with BE and LE.
> > >
> > > But the original test case only checks for cpu-types (processor
> > > version)
> > > but not for endianness, it means for the bif usages, there should
> > > not
> > > be
> > > different for endianness. Why does this changes with your new
> > > test
> > > case?
> > > Could you have a further look and make it consistent with some
> > > adjustment
> > > if possible? As we know, checking insn counts sometimes are
> > > fragile,
> > > so
> > > I think we should try our best to make it as robust as possible
> > > in
> > > the
> > > first place.
> > >
> > > Besides, the original case also have some differences between
> > > p7/p8
> > > and
> > > p9.
> > >
> >
> > There are differences on P8 LE versus BE. I did a diff between the
> > P8
> > and P9 tests:
> >
> > diff vsx-vector-6.p8.c vsx-vector-6.p9.c
> > 3,4c3,4
> > < /* { dg-require-effective-target powerpc_p8vector_ok } */
> > < /* { dg-options "-O2 -mdejagnu-cpu=power8" } */
> > ---
> > > /* { dg-require-effective-target powerpc_p9vector_ok } */
> > > /* { dg-options "-O2 -mdejagnu-cpu=power9" } */
> > 12c12
> > < /* { dg-final { scan-assembler-times {\mvperm\M} 1 } } */
> > ---
> > > /* { dg-final { scan-assembler-times {\m(?:v|xx)permr?\M} 1 } }
> > > */
> > 23d22
> > < /* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
> > 37c36
> > < /* { dg-final { scan-assembler-times {\mxvsubdp\M} 1 } } */
> > ---
> > > /* { dg-final { scan-assembler-times {\mxvmsub[am]dp\M} 1 } } */
> >
> > So we can see the vperm, vpermr, xxpermr, xvmsubadp, xvmsubmdp,
> > xvsubdp, xvmsubadp, xvmsubmdp instruction count checks are
> > different
> > between the two architectures. I then wrote a script to compile
> > the
> > CPU specific test on Power 8, Power 9 and Power 10 architectures
> > and
> > then grep for the above list of instructions. If I run the scrip
> > on P8
> > BE and LE I get>
> >
> > Power 8 BE Power 8 LE Power 9 LE Power 9
> > BE Power 10 LE*
> > (makalu-
> > lp1) (genoa) (marlin) (nilram) (ltcd97-lp3)
> > instruction count count count count
> > count
> > vperm 1 1 0 0
> > 0
> > vpermr 0 0 0 0
> > 0
> > xxpermr 0 0 1 0
> > 1
> > xvmsubadp 1 0 1 1
> > 1
> > xvmsubmdp 0 1 0 0
> > 0
> > xvsubdp 1 1 1 1
> > 1
> >
>
> Thanks for looking into this and making this statistics.
>
> Is there a typo for column nilram? Otherwise, the below insn check
>
> /* { dg-final { scan-assembler-times {\m(?:v|xx)permr?\M} 1 } } */
>
> would fail there.
Yes, there is a typo in the nilram column. The test generates a vperm
instruction.
#if defined (__BIG_ENDIAN__) || defined (_ARCH_PWR9)
dst[8].d = vec_perm (src0[8].d, src1[8].d, src2[8].uc);
f74: e9 3f 00 78 ld r9,120(r31)
f78: 39 29 07 00 addi r9,r9,1792
f7c: f5 89 00 01 lxv vs12,0(r9)
f80: e9 3f 00 80 ld r9,128(r31)
f84: 39 29 07 00 addi r9,r9,1792
f88: f4 09 00 01 lxv vs0,0(r9)
f8c: e9 3f 00 88 ld r9,136(r31)
f90: 39 29 07 00 addi r9,r9,1792
f94: f4 09 00 89 lxv vs32,128(r9)
f98: e9 3f 00 70 ld r9,112(r31)
f9c: 39 29 07 00 addi r9,r9,1792
fa0: f0 2c 64 91 xxmr vs33,vs12
fa4: f1 a0 04 91 xxmr vs45,vs0
fa8: 10 01 68 2b vperm v0,v1,v13,v0
...
> <snip>
> >
> > I had played with putting -Wno-inline on the command line but that
> > didn't seem to make any difference. However, you suggestion of
> > __attribute__ ((noipa)) does prevent the inlining and we don't get
> > the
> > second copy of the instructions showing up. The inlining eliminated
> > the
> > LE/BE differences for xvmaxsp, xvminsp and xvmaxdp.
>
> -Winline is a option for warning: "Warn if a function that is
> declared
> as inline cannot be inlined.", I think what you wanted is -fno-
> inline,
> and it's good to know noipa helps here.
Yea, my bad. Didn't read the manual very carefully.
>
> > The instruction count test for xxlor in vsx-vector-6-func-2lop.c
> > differs on LE and BE vsx-vector-6-func-2op.c. I believe the
> > instruction is used with loads to reorder the data. I don't see
> > anyway
> > to get around the extra xxlor instructions and verify the vec_or
> > builtin test generates the instruction.
> >
>
> OK, I'm still curious how the loads cause the difference.
Yea, looks like there is something screwy going on. So, I started by
running the test:
make -j 1 && make check-gcc RUNTESTFLAGS="-v -v powerpc.exp=vsx-
vector-6-func-2lop.c " > out
on Makalu, P8 BE and verified the test gives 7 passes and no failures.
on genoa, P8 LE, I also verified the test gives 7 passes and no
failures.
Then I went in an intentionally changed the expected counts down by one
for each platform. The idea was to verify that the dg-final { scan-
assembler-times {\mxxlor\M} was being called.
on Makalu, I now get an error, as expected:
heck_cached_effective_target be: returning 1 for unix
is-effective-target: be 1 <<<< NOTE BE
gcc.target/powerpc/vsx-vector-6-func-2lop.c: \\mxxlor\\M found 32 times
FAIL: gcc.target/powerpc/vsx-vector-6-func-2lop.c scan-assembler-times
\\mxxlor\\M 31
on Genoa, I now get the error, as expected:
check_cached_effective_target le: returning 1 for
unix
is-effective-target: le
1
gcc.target/powerpc/vsx-vector-6-func-2lop.c: \\mxxlor\\M found 22
times
FAIL: gcc.target/powerpc/vsx-vector-6-func-2lop.c scan-assembler-times
\\mxxlor\\M 21
So, running the tests, gcc definitely thinks there should be 22 xxlor
on LE and 32 on BE.
So, went to look at the assembly to verify my comment on the difference
being related to the loads. I decided to actually count the
instructions just to verify the number in the assembly files. Before,
I just looked at the assembly briefly but didn't dig in very deep.
If I compile the tests and dump the assembly with:
gcc -g -mcpu=power8 -o vsx-vector-6-func-2lop vsx-vector-6-func-
2lop.c
objdump -S -d vsx-vector-6-func-2lop > vsx-vector-6-func-2lop.dump
grep xxlor vsx-vector-6-func-2lop.dump | wc
4 28 192
So we see 4 xxlor instructions not 32 as expeced for BE or 22 as
expected for LE as the test claims. I get the same count of 4 on both
makalu and on genoa. I like this approach because you can easily see
the relationship of the source and assembly. So, there seems to be
something screwy here as that is not even close to what the make script
/scan-assemblerthinks the counts should be.
Segher never liked the above way of looking at the assembly. He
prefers:
gcc -S -g -mcpu=power8 -o vsx-vector-6-func-2lop.s vsx-vector-6-func-
2lop.c
grep xxlor vsx-vector-6-func-2lop.s | wc
34 68 516
So, again, I get the same count of 34 on both makalu and genoa. But
again, that doesn't agree with what make script/scan-assembler thinks
the counts should be.
When I looked at the vsx-vector-6-func-2lop.s I see on BE:
....
lxvd2x 0,10,9
xxlor 0,12,0
xxlnor 0,0,0
...
I was guessing that it was adjusting the data layout from the load.
But looking again more carefully versus LE:
....
lxvd2x 0,31,9
xxpermdi 0,0,0,2
xxlor 0,12,0
xxlnor 0,0,0
xxpermdi 0,0,0,2
....
the xxpermdi is probably what is really doing the data layout change.
So, we have the issue that looking at the assembly gives different
instruction counts then what
dg-final { scan-assembler-times {\mxxlor\M} }
comes up with??? Now I am really confused. I don't know how the scan-
assembler-times works but I will go see if I can find it and see if I
can figure out what the issue is. I would expect that the scan-
assembler is working off the --save-temp files, which get deleted as
part of the run. I would guess that scan-assembler does a grep to find
the instructions and then maybe uses wc to count them??? I will go see
if I can figure out how scan-assembler-times works.
Carl
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-30 22:20 ` Carl Love
@ 2023-06-30 23:50 ` Carl Love
2023-07-01 0:03 ` Peter Bergner
2023-06-30 23:59 ` Peter Bergner
2023-07-03 15:57 ` Carl Love
2 siblings, 1 reply; 12+ messages in thread
From: Carl Love @ 2023-06-30 23:50 UTC (permalink / raw)
To: Kewen.Lin, cel
Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Kewen:
On Fri, 2023-06-30 at 15:20 -0700, Carl Love wrote:
> So, went to look at the assembly to verify my comment on the
> difference
> being related to the loads. I decided to actually count the
> instructions just to verify the number in the assembly files.
> Before,
> I just looked at the assembly briefly but didn't dig in very deep.
>
> If I compile the tests and dump the assembly with:
> gcc -g -mcpu=power8 -o vsx-vector-6-func-2lop vsx-vector-6-func-
> 2lop.c
>
> objdump -S -d vsx-vector-6-func-2lop > vsx-vector-6-func-2lop.dump
>
> grep xxlor vsx-vector-6-func-2lop.dump | wc
> 4 28 192
>
> So we see 4 xxlor instructions not 32 as expeced for BE or 22 as
> expected for LE as the test claims. I get the same count of 4 on
> both
> makalu and on genoa.
With a little help from Peter and Julian Wang. Objdump decodes some of
the xxlor instructions as xxmr instsructions. The xxmr is a new
mnemonic which will be out in the next ISA. But objdump already
produces it. So if you add the counts for grep xxlor and grep xxmr you
get a total of 34 which agress with the count of xxlor in the gcc -S
generated assembly.
Carl
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-30 22:20 ` Carl Love
2023-06-30 23:50 ` Carl Love
@ 2023-06-30 23:59 ` Peter Bergner
2023-07-03 15:57 ` Carl Love
2 siblings, 0 replies; 12+ messages in thread
From: Peter Bergner @ 2023-06-30 23:59 UTC (permalink / raw)
To: Carl Love, Kewen.Lin
Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
On 6/30/23 5:20 PM, Carl Love wrote:
> So, we have the issue that looking at the assembly gives different
> instruction counts then what
>
> dg-final { scan-assembler-times {\mxxlor\M} }
>
> comes up with???
I recommend not even counting xxlor at all, since the majority of
them come from vsx register copies and whether and how many we
generate seemingly varies with the phase of the moon, day of the
week, etc. etc.
If you really want to verify an xxlor count, you almost have to extract
the given test into it's own file so it's not corrupted by any of the
other tests and it has to be as small as possible and compiled with
a fair amount of optimization. Even then you may get some copies.
So I'd recommend just removing the xxlor counts altogether.
Peter
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-30 23:50 ` Carl Love
@ 2023-07-01 0:03 ` Peter Bergner
0 siblings, 0 replies; 12+ messages in thread
From: Peter Bergner @ 2023-07-01 0:03 UTC (permalink / raw)
To: Carl Love, Kewen.Lin; +Cc: Segher Boessenkool, gcc-patches, David Edelsohn
On 6/30/23 6:50 PM, Carl Love wrote:
> With a little help from Peter and Julian Wang. Objdump decodes some of
> the xxlor instructions as xxmr instsructions. The xxmr is a new
> mnemonic which will be out in the next ISA. But objdump already
> produces it. So if you add the counts for grep xxlor and grep xxmr you
> get a total of 34 which agress with the count of xxlor in the gcc -S
> generated assembly.
Right, xxmr is new and objdump defaults to emitting it for xxlor's used
as copies. You can use the -Mraw objdump option to display the real
mnemonics instead of any extended mnemonics.
Peter
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-06-30 22:20 ` Carl Love
2023-06-30 23:50 ` Carl Love
2023-06-30 23:59 ` Peter Bergner
@ 2023-07-03 15:57 ` Carl Love
2023-07-04 2:08 ` Kewen.Lin
2 siblings, 1 reply; 12+ messages in thread
From: Carl Love @ 2023-07-03 15:57 UTC (permalink / raw)
To: Kewen.Lin; +Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Kewen:
On Fri, 2023-06-30 at 15:20 -0700, Carl Love wrote:
> Segher never liked the above way of looking at the assembly. He
> prefers:
> gcc -S -g -mcpu=power8 -o vsx-vector-6-func-2lop.s vsx-vector-6-
> func-
> 2lop.c
>
> grep xxlor vsx-vector-6-func-2lop.s | wc
> 34 68 516
>
> So, again, I get the same count of 34 on both makalu and genoa. But
> again, that doesn't agree with what make script/scan-assembler thinks
> the counts should be.
>
> When I looked at the vsx-vector-6-func-2lop.s I see on BE:
>
> ....
> lxvd2x 0,10,9
> xxlor 0,12,0
> xxlnor 0,0,0
> ...
>
> I was guessing that it was adjusting the data layout from the load.
> But looking again more carefully versus LE:
>
> ....
> lxvd2x 0,31,9
> xxpermdi 0,0,0,2
> xxlor 0,12,0
> xxlnor 0,0,0
> xxpermdi 0,0,0,2
> ....
>
> the xxpermdi is probably what is really doing the data layout change.
>
> So, we have the issue that looking at the assembly gives different
> instruction counts then what
>
> dg-final { scan-assembler-times {\mxxlor\M} }
>
> comes up with??? Now I am really confused. I don't know how the
> scan-
> assembler-times works but I will go see if I can find it and see if I
> can figure out what the issue is. I would expect that the scan-
> assembler is working off the --save-temp files, which get deleted as
> part of the run. I would guess that scan-assembler does a grep to
> find
> the instructions and then maybe uses wc to count them??? I will go
> see
> if I can figure out how scan-assembler-times works.
OK, I figured out why I was getting 34 xxlor instructions instead of
the 22 that the scan-assembler-times was getting. The difference was
when I compiled the program I forgot to use -O2. So with -O2 I get the
same number of xxlor instructins as scan-assembler-instructions. I get
34 if I do not specify optimization.
So, I think the scan-assembler-times are all correct.
As Peter says, counting xxlor is a bit problematic in general. We
could just drop counting xxlor or have the LE/BE count qualifier for
the instructions. Your call.
Carl
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] rs6000: Update the vsx-vector-6.* tests.
2023-07-03 15:57 ` Carl Love
@ 2023-07-04 2:08 ` Kewen.Lin
0 siblings, 0 replies; 12+ messages in thread
From: Kewen.Lin @ 2023-07-04 2:08 UTC (permalink / raw)
To: Carl Love; +Cc: Peter Bergner, Segher Boessenkool, gcc-patches, David Edelsohn
Hi Carl,
on 2023/7/3 23:57, Carl Love wrote:
> Kewen:
>
> On Fri, 2023-06-30 at 15:20 -0700, Carl Love wrote:
>> Segher never liked the above way of looking at the assembly. He
>> prefers:
>> gcc -S -g -mcpu=power8 -o vsx-vector-6-func-2lop.s vsx-vector-6-
>> func-
>> 2lop.c
>>
>> grep xxlor vsx-vector-6-func-2lop.s | wc
>> 34 68 516
>>
>> So, again, I get the same count of 34 on both makalu and genoa. But
>> again, that doesn't agree with what make script/scan-assembler thinks
>> the counts should be.
>>
>> When I looked at the vsx-vector-6-func-2lop.s I see on BE:
>>
>> ....
>> lxvd2x 0,10,9
>> xxlor 0,12,0
>> xxlnor 0,0,0
>> ...
>>
>> I was guessing that it was adjusting the data layout from the load.
>> But looking again more carefully versus LE:
>>
>> ....
>> lxvd2x 0,31,9
>> xxpermdi 0,0,0,2
>> xxlor 0,12,0
>> xxlnor 0,0,0
>> xxpermdi 0,0,0,2
>> ....
>>
>> the xxpermdi is probably what is really doing the data layout change.
>>
>> So, we have the issue that looking at the assembly gives different
>> instruction counts then what
>>
>> dg-final { scan-assembler-times {\mxxlor\M} }
>>
>> comes up with??? Now I am really confused. I don't know how the
>> scan-
>> assembler-times works but I will go see if I can find it and see if I
>> can figure out what the issue is. I would expect that the scan-
>> assembler is working off the --save-temp files, which get deleted as
>> part of the run. I would guess that scan-assembler does a grep to
>> find
>> the instructions and then maybe uses wc to count them??? I will go
>> see
>> if I can figure out how scan-assembler-times works.
>
> OK, I figured out why I was getting 34 xxlor instructions instead of
> the 22 that the scan-assembler-times was getting. The difference was
> when I compiled the program I forgot to use -O2. So with -O2 I get the
> same number of xxlor instructins as scan-assembler-instructions. I get
> 34 if I do not specify optimization.
OK, thanks for looking into it. When you run a test case with RUNTESTFLAGS,
you can add the "-v" (and even more times) to RUNTESTFLAGS, then you can find
the exact compiling commands in the dumping, I usually used this way for
reproducing and I hope it can avoid some inconsistency for reproduction.
>
> So, I think the scan-assembler-times are all correct.
>
> As Peter says, counting xxlor is a bit problematic in general. We
> could just drop counting xxlor or have the LE/BE count qualifier for
> the instructions. Your call.
Yeah, I agree that counting xxlor in the checking code (from function main)
is fragile, but as you said we still want to check expected xxlor generated
for bif vec_or, so I'd prefer to separate the existing case into the
compiling part and run part, I'll reply with more details to your latest v3.
Thanks,
Kewen
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-07-04 2:08 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30 20:46 [PATCH] rs6000: Update the vsx-vector-6.* tests Carl Love
2023-06-19 7:17 ` Kewen.Lin
2023-06-21 22:42 ` Carl Love
2023-06-28 8:35 ` Kewen.Lin
2023-06-29 21:36 ` Carl Love
2023-06-30 3:37 ` Kewen.Lin
2023-06-30 22:20 ` Carl Love
2023-06-30 23:50 ` Carl Love
2023-07-01 0:03 ` Peter Bergner
2023-06-30 23:59 ` Peter Bergner
2023-07-03 15:57 ` Carl Love
2023-07-04 2:08 ` 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).