[05/11] rs6000, __builtin_vsx_xvneg[sp,dp] add documentation, and test cases
Checks
Commit Message
GCC maintainers:
The patch adds documentation and test cases for the __builtin_vsx_xvnegsp, __builtin_vsx_xvnegdp built-ins.
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, __builtin_vsx_xvneg[sp,dp] add documentation and test cases
Add documentation to the extend.texi file for the two built-ins
__builtin_vsx_xvnegsp, __builtin_vsx_xvnegdp.
Add test cases for the two built-ins.
gcc/ChangeLog:
* doc/extend.texi (__builtin_vsx_xvnegsp, __builtin_vsx_xvnegdp):
Add documentation.
gcc/testsuite/ChangeLog:
* gcc.target/powerpc/vsx-builtin-runnable-2.c: New test case.
---
gcc/doc/extend.texi | 13 +++++
.../powerpc/vsx-builtin-runnable-2.c | 51 +++++++++++++++++++
2 files changed, 64 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-2.c
Comments
Hi,
on 2024/2/21 01:56, Carl Love wrote:
> GCC maintainers:
>
> The patch adds documentation and test cases for the __builtin_vsx_xvnegsp, __builtin_vsx_xvnegdp built-ins.
>
> 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, __builtin_vsx_xvneg[sp,dp] add documentation and test cases
>
> Add documentation to the extend.texi file for the two built-ins
> __builtin_vsx_xvnegsp, __builtin_vsx_xvnegdp.
I think these two are useless, the functionality has been covered by vec_neg
in PVIPR, so instead we should get rid of these definitions (bif def table,
test cases if there are some).
BR,
Kewen
>
> Add test cases for the two built-ins.
>
> gcc/ChangeLog:
> * doc/extend.texi (__builtin_vsx_xvnegsp, __builtin_vsx_xvnegdp):
> Add documentation.
>
> gcc/testsuite/ChangeLog:
> * gcc.target/powerpc/vsx-builtin-runnable-2.c: New test case.
> ---
> gcc/doc/extend.texi | 13 +++++
> .../powerpc/vsx-builtin-runnable-2.c | 51 +++++++++++++++++++
> 2 files changed, 64 insertions(+)
> create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-2.c
>
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index 583b1d890bf..83eed9e334b 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -21495,6 +21495,19 @@ The @code{__builtin_vsx_xvcvuxwdp} converts single precision unsigned integer
> value to a double precision floating point value. Input element at index 2*i
> is stored in the destination element i.
>
> +@smallexample
> +vector float __builtin_vsx_xvnegsp (vector float);
> +vector double __builtin_vsx_xvnegdp (vector double);
> +@end smallexample
> +
> +The @code{__builtin_vsx_xvnegsp} and @code{__builtin_vsx_xvnegdp} negate each
> +vector element.
> +
> +@smallexample
> +vector __int128 __builtin_vsx_xxpermdi_1ti (vector __int128, vector __int128,
> +const int);
> +
> +@end smallexample
> @node Basic PowerPC Built-in Functions Available on ISA 2.07
> @subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
>
> diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-2.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-2.c
> new file mode 100644
> index 00000000000..7906a8e01d7
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-2.c
> @@ -0,0 +1,51 @@
> +/* { dg-do run { target { lp64 } } } */
> +/* { dg-require-effective-target powerpc_vsx_ok } */
> +/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
> +
> +#define DEBUG 0
> +
> +#if DEBUG
> +#include <stdio.h>
> +#include <stdlib.h>
> +#endif
> +
> +void abort (void);
> +
> +int main ()
> +{
> + int i;
> + vector double vd_arg1, vd_result, vd_expected_result;
> + vector float vf_arg1, vf_result, vf_expected_result;
> +
> + /* VSX Vector Negate Single-Precision. */
> +
> + vf_arg1 = (vector float) {-1.0, 12345.98, -2.1234, 238.9};
> + vf_result = __builtin_vsx_xvnegsp (vf_arg1);
> + vf_expected_result = (vector float) {1.0, -12345.98, 2.1234, -238.9};
> +
> + for (i = 0; i < 4; i++)
> + if (vf_result[i] != vf_expected_result[i])
> +#if DEBUG
> + printf("ERROR, __builtin_vsx_xvnegsp: vf_result[%d] = %f, vf_expected_result[%d] = %f\n",
> + i, vf_result[i], i, vf_expected_result[i]);
> +#else
> + abort();
> +#endif
> +
> + /* VSX Vector Negate Double-Precision. */
> +
> + vd_arg1 = (vector double) {12345.98, -2.1234};
> + vd_result = __builtin_vsx_xvnegdp (vd_arg1);
> + vd_expected_result = (vector double) {-12345.98, 2.1234};
> +
> + for (i = 0; i < 2; i++)
> + if (vd_result[i] != vd_expected_result[i])
> +#if DEBUG
> + printf("ERROR, __builtin_vsx_xvnegdp: vd_result[%d] = %f, vd_expected_result[%d] = %f\n",
> + i, vd_result[i], i, vd_expected_result[i]);
> +#else
> + abort();
> +#endif
> +
> + return 0;
> +}
@@ -21495,6 +21495,19 @@ The @code{__builtin_vsx_xvcvuxwdp} converts single precision unsigned integer
value to a double precision floating point value. Input element at index 2*i
is stored in the destination element i.
+@smallexample
+vector float __builtin_vsx_xvnegsp (vector float);
+vector double __builtin_vsx_xvnegdp (vector double);
+@end smallexample
+
+The @code{__builtin_vsx_xvnegsp} and @code{__builtin_vsx_xvnegdp} negate each
+vector element.
+
+@smallexample
+vector __int128 __builtin_vsx_xxpermdi_1ti (vector __int128, vector __int128,
+const int);
+
+@end smallexample
@node Basic PowerPC Built-in Functions Available on ISA 2.07
@subsubsection Basic PowerPC Built-in Functions Available on ISA 2.07
new file mode 100644
@@ -0,0 +1,51 @@
+/* { dg-do run { target { lp64 } } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mdejagnu-cpu=power7" } */
+
+#define DEBUG 0
+
+#if DEBUG
+#include <stdio.h>
+#include <stdlib.h>
+#endif
+
+void abort (void);
+
+int main ()
+{
+ int i;
+ vector double vd_arg1, vd_result, vd_expected_result;
+ vector float vf_arg1, vf_result, vf_expected_result;
+
+ /* VSX Vector Negate Single-Precision. */
+
+ vf_arg1 = (vector float) {-1.0, 12345.98, -2.1234, 238.9};
+ vf_result = __builtin_vsx_xvnegsp (vf_arg1);
+ vf_expected_result = (vector float) {1.0, -12345.98, 2.1234, -238.9};
+
+ for (i = 0; i < 4; i++)
+ if (vf_result[i] != vf_expected_result[i])
+#if DEBUG
+ printf("ERROR, __builtin_vsx_xvnegsp: vf_result[%d] = %f, vf_expected_result[%d] = %f\n",
+ i, vf_result[i], i, vf_expected_result[i]);
+#else
+ abort();
+#endif
+
+ /* VSX Vector Negate Double-Precision. */
+
+ vd_arg1 = (vector double) {12345.98, -2.1234};
+ vd_result = __builtin_vsx_xvnegdp (vd_arg1);
+ vd_expected_result = (vector double) {-12345.98, 2.1234};
+
+ for (i = 0; i < 2; i++)
+ if (vd_result[i] != vd_expected_result[i])
+#if DEBUG
+ printf("ERROR, __builtin_vsx_xvnegdp: vd_result[%d] = %f, vd_expected_result[%d] = %f\n",
+ i, vd_result[i], i, vd_expected_result[i]);
+#else
+ abort();
+#endif
+
+ return 0;
+}