GCC maintainers:
The patch adds documentation and test case for the __builtin_vsx_xvcmpeq[sp, dp, sp_p] 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_xvcmpeq[sp, dp, sp_p] add documentation and test case Add a test case for the __builtin_vsx_xvcmpeqsp_p built-in. Add documentation for the __builtin_vsx_xvcmpeqsp_p, __builtin_vsx_xvcmpeqdp, and __builtin_vsx_xvcmpeqsp builtins. gcc/ChangeLog: * doc/extend.texi (__builtin_vsx_xvcmpeqsp_p, __builtin_vsx_xvcmpeqdp, __builtin_vsx_xvcmpeqsp): Add documentation. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vsx-builtin-runnable-4.c: New test case. --- gcc/doc/extend.texi | 23 +++ .../powerpc/vsx-builtin-runnable-4.c | 135 ++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 22f67ebab31..87fd30bfa9e 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -22700,6 +22700,18 @@ vectors of their defined type. The corresponding result element is set to all ones if the two argument elements are less than or equal and all zeros otherwise. +@smallexample +const vf __builtin_vsx_xvcmpeqsp (vf, vf); +const vd __builtin_vsx_xvcmpeqdp (vd, vd); +@end smallexample + +The builti-ins @code{__builtin_vsx_xvcmpeqdp} and +@code{__builtin_vsx_xvcmpeqdp} compare two floating point vectors and return +a vector. If the corresponding elements are equal then the corresponding +vector element of the result is set to all ones, it is set to all zeros +otherwise. + + @node PowerPC AltiVec Built-in Functions Available on ISA 2.07 @subsubsection PowerPC AltiVec Built-in Functions Available on ISA 2.07 @@ -23989,6 +24001,17 @@ is larger than 128 bits, the result is undefined. The result is the modulo result of dividing the first input by the second input. +@smallexample +const signed int __builtin_vsx_xvcmpeqdp_p (signed int, vd, vd); +@end smallexample + +The first argument of the builti-in @code{__builtin_vsx_xvcmpeqdp_p} is an +integer in the range of 0 to 1. The second and third arguments are floating +point vectors to be compared. The result is 1 if the first argument is a 1 +and one or more of the corresponding vector elements are equal. The result is +1 if the first argument is 0 and all of the corresponding vector elements are +not equal. The result is zero otherwise. + The following builtins perform 128-bit vector comparisons. The @code{vec_all_xx}, @code{vec_any_xx}, and @code{vec_cmpxx}, where @code{xx} is one of the operations @code{eq, ne, gt, lt, ge, le} perform pairwise diff --git a/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c new file mode 100644 index 00000000000..8ac07c7c807 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vsx-builtin-runnable-4.c @@ -0,0 +1,135 @@ +/* { dg-do run { target { power10_hw } } } */ +/* { dg-do link { target { ! power10_hw } } } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2 -save-temps" } */ +/* { dg-require-effective-target power10_ok } */ + +#define DEBUG 0 + +#if DEBUG +#include <stdio.h> +#include <stdlib.h> +#endif + +void abort (void); + +int main () +{ + int i; + int result; + vector float vf_arg1, vf_arg2; + vector double d_arg1, d_arg2; + + /* Compare vectors with one equal element, check + for all elements unequal, i.e. first arg is 1. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (1, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 1) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 1: arg 1 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + /* Compare vectors with one equal element, check + for all elements unequal, i.e. first arg is 0. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (0, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 0) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 2: arg 1 = 0, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all unequal elements, check + for all elements unequal, i.e. first arg is 1. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {8.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (1, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 0) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 3: arg 1 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all unequal elements, check + for all elements unequal, i.e. first arg is 0. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {8.0, 3.0, 2.0, 8.0}; + result = __builtin_vsx_xvcmpeqsp_p (0, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 1) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 4: arg 1 = 0, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all equal elements, check + for all elements equal, i.e. first arg is 1. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 2.0, 3.0, 4.0}; + result = __builtin_vsx_xvcmpeqsp_p (1, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 1) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 5: arg 1 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + + /* Compare vectors with all equal elements, check + for all elements unequal, i.e. first arg is 0. */ + vf_arg1 = (vector float) {1.0, 2.0, 3.0, 4.0}; + vf_arg2 = (vector float) {1.0, 2.0, 3.0, 4.0}; + result = __builtin_vsx_xvcmpeqsp_p (0, vf_arg1, vf_arg2); + +#if DEBUG + printf("result = 0x%x\n", (unsigned int) result); +#endif + + if (result != 0) + for (i = 0; i < 4; i++) +#if DEBUG + printf("ERROR, __builtin_vsx_xvcmpeqsp_p 6: arg 0 = 1, varg3[%d] = %f, varg3[%d] = %f\n", + i, vf_arg1[i], i, vf_arg2[i]); +#else + abort(); +#endif + return 0; +} -- 2.43.0