From: Carl Love Date: Wed, 9 May 2018 19:21:24 +0000 (+0000) Subject: builtins-8-runnable.c: New builtin test file. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eb1d9e8e6f53b80230752556f4f6c5e4e6cb948f;p=gcc.git builtins-8-runnable.c: New builtin test file. gcc/testsuite/ChangeLog: 2018-05-09 Carl Love * gcc.target/powerpc/builtins-8-runnable.c: New builtin test file. From-SVN: r260090 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f1c39526a5..316415901a9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,6 @@ +2018-05-09 Carl Love + * gcc.target/powerpc/builtins-8-runnable.c: New builtin test file. + 2018-05-09 Paolo Carlini PR c++/85713 diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-8-runnable.c b/gcc/testsuite/gcc.target/powerpc/builtins-8-runnable.c new file mode 100644 index 00000000000..26b26d58084 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/builtins-8-runnable.c @@ -0,0 +1,98 @@ +/* { dg-do run { target { powerpc*-*-* && { p8vector_hw } } } } */ +/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ +/* { dg-options "-mcpu=power8 -O2" } */ + +#include +#include +#include +#include + +#ifdef DEBUG +#include +#endif + +void abort (void); + +int main() + { + int i; + vector float f_arg1; + vector double d_arg1; + + vector float vec_f_expected1, vec_f_result1, vec_f_error; + vector double vec_d_expected1, vec_d_result1, vec_d_error; + + /* vec_expte: float args, result */ + f_arg1 = (vector float){1.0, 2.0, 3.0, 4.0}; + vec_f_expected1 = (vector float){2.0, 4.0, 8.0, 16.0}; + + vec_f_result1 = vec_expte (f_arg1); + + for (i = 0; i < 4; i++) + { + if (vec_f_expected1[i] != vec_f_result1[i]) +#ifdef DEBUG + printf("ERROR vec_expte (f) result[%d]=%f != expected[%d]=%f\n", + i, vec_f_result1[i], i, vec_f_expected1[i]); +#else + abort(); +#endif + } + + /* vec_loge: float args, result */ + f_arg1 = (vector float){4.0, 8.0, 16.0, 64}; + vec_f_expected1 = (vector float){2.0, 3.0, 4.0, 6.0}; + + vec_f_result1 = vec_loge (f_arg1); + + for (i = 0; i < 4; i++) + { + if (vec_f_expected1[i] != vec_f_result1[i]) +#ifdef DEBUG + printf("ERROR vec_loge (f) result[%d]=%f != expected[%d]=%f\n", + i, vec_f_result1[i], i, vec_f_expected1[i]); +#else + abort(); +#endif + } + + /* vec_re: float args, result (calculate approximate reciprocal) */ + f_arg1 = (vector float){1.0, 5.0, 4.0, 8.0}; + vec_f_expected1 = (vector float){1.0, 0.2, 0.25, 0.125}; + vec_f_error = (vector float){1.0, 0.2, 0.25, 0.125}; + + vec_f_result1 = vec_re (f_arg1); + + for (i = 0; i < 4; i++) + { + vec_f_error[i] = fabs(vec_f_expected1[i] - vec_f_result1[i]); + + if (vec_f_error[i] >= 0.0001) +#ifdef DEBUG + printf("ERROR vec_re (f) result[%d]=%f != expected[%d]=%f\n", + i, vec_f_result1[i], i, vec_f_expected1[i]); +#else + abort(); +#endif + } + + /* vec_re: double args, result (calculate approximate reciprocal) */ + d_arg1 = (vector double){1.0, 8.0}; + vec_d_expected1 = (vector double){1.0, 0.125}; + vec_d_error = (vector double){1.0, 0.125}; + + vec_d_result1 = vec_re (d_arg1); + + for (i = 0; i < 2; i++) + { + vec_d_error[i] = fabs(vec_d_expected1[i] - vec_d_result1[i]); + + if (vec_d_error[i] >= 0.0001) +#ifdef DEBUG + printf("ERROR vec_re (d) result[%d]=%f != expected[%d]=%f\n", + i, vec_d_result1[i], i, vec_d_expected1[i]); +#else + abort(); +#endif + } + }