Message ID | 20231007062530.20048-1-pan2.li@intel.com |
---|---|
State | New |
Headers | show |
Series | [v1] RISC-V: Add more run test for FP rounding autovec | expand |
OK juzhe.zhong@rivai.ai From: pan2.li Date: 2023-10-07 14:25 To: gcc-patches CC: juzhe.zhong; pan2.li; yanzhang.wang; kito.cheng Subject: [PATCH v1] RISC-V: Add more run test for FP rounding autovec From: Pan Li <pan2.li@intel.com> For _Float16 types, add run test for: * ceil * floor * nearbyint * rint * round * roundeven * trunc For float and double, add run test for: * roundeven The zfa extension is required for these run test cases, the simulation target_board may look like below for rv64. target_board="riscv-sim/-march=rv64gcv_zfa_zfh/-mabi=lp64d/-mcmodel=medlow" gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/rvv.exp: Add zfa for building. * gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com> --- .../riscv/rvv/autovec/unop/math-ceil-run-0.c | 39 +++++++++++++++ .../riscv/rvv/autovec/unop/math-floor-run-0.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-nearbyint-run-0.c | 48 +++++++++++++++++++ .../riscv/rvv/autovec/unop/math-rint-run-0.c | 48 +++++++++++++++++++ .../riscv/rvv/autovec/unop/math-round-run-0.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-roundeven-run-0.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-roundeven-run-1.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-roundeven-run-2.c | 39 +++++++++++++++ .../riscv/rvv/autovec/unop/math-trunc-run-0.c | 39 +++++++++++++++ gcc/testsuite/gcc.target/riscv/rvv/rvv.exp | 4 +- 10 files changed, 371 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c new file mode 100644 index 00000000000..70cba3602bb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_ceilf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 2.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c new file mode 100644 index 00000000000..c542278c1f5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_floorf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 8388609.0, 8388609.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c new file mode 100644 index 00000000000..5339fb9c03b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c @@ -0,0 +1,48 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_nearbyintf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + unsigned fflags_before = get_fflags (); + + set_rm (FRM_RTZ); + + RUN_TEST (_Float16, 1, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + + unsigned fflags_after = get_fflags (); + + if (fflags_before != fflags_after) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c new file mode 100644 index 00000000000..5667ee111d3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c @@ -0,0 +1,48 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_rintf) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + unsigned fflags_before = get_fflags (); + + set_rm (FRM_RTZ); + + RUN_TEST (_Float16, 1, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_rintf, in, out, ref, ARRAY_SIZE); + + unsigned fflags_after = get_fflags (); + + if (fflags_before == fflags_after) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c new file mode 100644 index 00000000000..f0fc51970be --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_roundf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.6, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c new file mode 100644 index 00000000000..9ef39993ca4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_roundevenf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.5, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c new file mode 100644 index 00000000000..b1918bad45e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +float in[ARRAY_SIZE]; +float out[ARRAY_SIZE]; +float ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (float, __builtin_roundf) +TEST_ASSERT (float) + +TEST_INIT (float, 1.2, 1.0, 1) +TEST_INIT (float, -1.5, -2.0, 2) +TEST_INIT (float, 3.0, 3.0, 3) +TEST_INIT (float, 8388607.5, 8388608.0, 4) +TEST_INIT (float, 8388609.0, 8388609.0, 5) +TEST_INIT (float, 0.0, 0.0, 6) +TEST_INIT (float, -0.0, -0.0, 7) +TEST_INIT (float, -8388607.5, -8388608.0, 8) +TEST_INIT (float, -8388608.0, -8388608.0, 9) + +int +main () +{ + RUN_TEST (float, 1, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 2, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 3, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 4, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 5, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 6, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 7, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 8, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 9, __builtin_roundf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c new file mode 100644 index 00000000000..9f037b4c908 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +double in[ARRAY_SIZE]; +double out[ARRAY_SIZE]; +double ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (double, __builtin_round) +TEST_ASSERT (double) + +TEST_INIT (double, 1.2, 1.0, 1) +TEST_INIT (double, -1.5, -2.0, 2) +TEST_INIT (double, 3.0, 3.0, 3) +TEST_INIT (double, 4503599627370495.5, 4503599627370496.0, 4) +TEST_INIT (double, 4503599627370497.0, 4503599627370497.0, 5) +TEST_INIT (double, 0.0, 0.0, 6) +TEST_INIT (double, -0.0, -0.0, 7) +TEST_INIT (double, -4503599627370495.5, -4503599627370496.0, 8) +TEST_INIT (double, -4503599627370496.0, -4503599627370496.0, 9) + +int +main () +{ + RUN_TEST (double, 1, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 2, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 3, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 4, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 5, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 6, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 7, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 8, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 9, __builtin_round, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c new file mode 100644 index 00000000000..340acb5994c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_truncf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp index ff76e17d0e6..87d3e8f9a06 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp +++ b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp @@ -30,10 +30,10 @@ if ![info exists DEFAULT_CFLAGS] then { set DEFAULT_CFLAGS " -ansi -pedantic-errors" } -set gcc_march "rv64gcv_zfh" +set gcc_march "rv64gcv_zfa_zfh" set gcc_mabi "lp64d" if [istarget riscv32-*-*] then { - set gcc_march "rv32gcv_zfh" + set gcc_march "rv32gcv_zfa_zfh" set gcc_mabi "ilp32d" }
Committed, thanks Juzhe.
Pan
From: juzhe.zhong@rivai.ai <juzhe.zhong@rivai.ai>
Sent: Saturday, October 7, 2023 2:38 PM
To: Li, Pan2 <pan2.li@intel.com>; gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Li, Pan2 <pan2.li@intel.com>; Wang, Yanzhang <yanzhang.wang@intel.com>; kito.cheng <kito.cheng@gmail.com>
Subject: Re: [PATCH v1] RISC-V: Add more run test for FP rounding autovec
OK
These testcases cause multiple FAILs: I think you should /* { dg-do run { target { riscv_v && riscv_zvfh_hw && riscv_zfh_ok } } } */ juzhe.zhong@rivai.ai From: pan2.li Date: 2023-10-07 14:25 To: gcc-patches CC: juzhe.zhong; pan2.li; yanzhang.wang; kito.cheng Subject: [PATCH v1] RISC-V: Add more run test for FP rounding autovec From: Pan Li <pan2.li@intel.com> For _Float16 types, add run test for: * ceil * floor * nearbyint * rint * round * roundeven * trunc For float and double, add run test for: * roundeven The zfa extension is required for these run test cases, the simulation target_board may look like below for rv64. target_board="riscv-sim/-march=rv64gcv_zfa_zfh/-mabi=lp64d/-mcmodel=medlow" gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/rvv.exp: Add zfa for building. * gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c: New test. * gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c: New test. Signed-off-by: Pan Li <pan2.li@intel.com> --- .../riscv/rvv/autovec/unop/math-ceil-run-0.c | 39 +++++++++++++++ .../riscv/rvv/autovec/unop/math-floor-run-0.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-nearbyint-run-0.c | 48 +++++++++++++++++++ .../riscv/rvv/autovec/unop/math-rint-run-0.c | 48 +++++++++++++++++++ .../riscv/rvv/autovec/unop/math-round-run-0.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-roundeven-run-0.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-roundeven-run-1.c | 39 +++++++++++++++ .../rvv/autovec/unop/math-roundeven-run-2.c | 39 +++++++++++++++ .../riscv/rvv/autovec/unop/math-trunc-run-0.c | 39 +++++++++++++++ gcc/testsuite/gcc.target/riscv/rvv/rvv.exp | 4 +- 10 files changed, 371 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c new file mode 100644 index 00000000000..70cba3602bb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_ceilf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 2.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c new file mode 100644 index 00000000000..c542278c1f5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_floorf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 8388609.0, 8388609.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c new file mode 100644 index 00000000000..5339fb9c03b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c @@ -0,0 +1,48 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_nearbyintf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + unsigned fflags_before = get_fflags (); + + set_rm (FRM_RTZ); + + RUN_TEST (_Float16, 1, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + + unsigned fflags_after = get_fflags (); + + if (fflags_before != fflags_after) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c new file mode 100644 index 00000000000..5667ee111d3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c @@ -0,0 +1,48 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_rintf) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + unsigned fflags_before = get_fflags (); + + set_rm (FRM_RTZ); + + RUN_TEST (_Float16, 1, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_rintf, in, out, ref, ARRAY_SIZE); + + unsigned fflags_after = get_fflags (); + + if (fflags_before == fflags_after) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c new file mode 100644 index 00000000000..f0fc51970be --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_roundf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.6, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c new file mode 100644 index 00000000000..9ef39993ca4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_roundevenf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.5, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c new file mode 100644 index 00000000000..b1918bad45e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +float in[ARRAY_SIZE]; +float out[ARRAY_SIZE]; +float ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (float, __builtin_roundf) +TEST_ASSERT (float) + +TEST_INIT (float, 1.2, 1.0, 1) +TEST_INIT (float, -1.5, -2.0, 2) +TEST_INIT (float, 3.0, 3.0, 3) +TEST_INIT (float, 8388607.5, 8388608.0, 4) +TEST_INIT (float, 8388609.0, 8388609.0, 5) +TEST_INIT (float, 0.0, 0.0, 6) +TEST_INIT (float, -0.0, -0.0, 7) +TEST_INIT (float, -8388607.5, -8388608.0, 8) +TEST_INIT (float, -8388608.0, -8388608.0, 9) + +int +main () +{ + RUN_TEST (float, 1, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 2, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 3, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 4, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 5, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 6, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 7, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 8, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 9, __builtin_roundf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c new file mode 100644 index 00000000000..9f037b4c908 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +double in[ARRAY_SIZE]; +double out[ARRAY_SIZE]; +double ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (double, __builtin_round) +TEST_ASSERT (double) + +TEST_INIT (double, 1.2, 1.0, 1) +TEST_INIT (double, -1.5, -2.0, 2) +TEST_INIT (double, 3.0, 3.0, 3) +TEST_INIT (double, 4503599627370495.5, 4503599627370496.0, 4) +TEST_INIT (double, 4503599627370497.0, 4503599627370497.0, 5) +TEST_INIT (double, 0.0, 0.0, 6) +TEST_INIT (double, -0.0, -0.0, 7) +TEST_INIT (double, -4503599627370495.5, -4503599627370496.0, 8) +TEST_INIT (double, -4503599627370496.0, -4503599627370496.0, 9) + +int +main () +{ + RUN_TEST (double, 1, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 2, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 3, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 4, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 5, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 6, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 7, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 8, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 9, __builtin_round, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c new file mode 100644 index 00000000000..340acb5994c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_truncf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp index ff76e17d0e6..87d3e8f9a06 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp +++ b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp @@ -30,10 +30,10 @@ if ![info exists DEFAULT_CFLAGS] then { set DEFAULT_CFLAGS " -ansi -pedantic-errors" } -set gcc_march "rv64gcv_zfh" +set gcc_march "rv64gcv_zfa_zfh" set gcc_mabi "lp64d" if [istarget riscv32-*-*] then { - set gcc_march "rv32gcv_zfh" + set gcc_march "rv32gcv_zfa_zfh" set gcc_mabi "ilp32d" }
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c new file mode 100644 index 00000000000..70cba3602bb --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-ceil-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_ceilf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 2.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_ceilf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c new file mode 100644 index 00000000000..c542278c1f5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-floor-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_floorf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 8388609.0, 8388609.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_floorf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c new file mode 100644 index 00000000000..5339fb9c03b --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-nearbyint-run-0.c @@ -0,0 +1,48 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_nearbyintf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + unsigned fflags_before = get_fflags (); + + set_rm (FRM_RTZ); + + RUN_TEST (_Float16, 1, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_nearbyintf16, in, out, ref, ARRAY_SIZE); + + unsigned fflags_after = get_fflags (); + + if (fflags_before != fflags_after) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c new file mode 100644 index 00000000000..5667ee111d3 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-0.c @@ -0,0 +1,48 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_rintf) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + unsigned fflags_before = get_fflags (); + + set_rm (FRM_RTZ); + + RUN_TEST (_Float16, 1, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_rintf, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_rintf, in, out, ref, ARRAY_SIZE); + + unsigned fflags_after = get_fflags (); + + if (fflags_before == fflags_after) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c new file mode 100644 index 00000000000..f0fc51970be --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-round-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_roundf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.6, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_roundf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c new file mode 100644 index 00000000000..9ef39993ca4 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_roundevenf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.5, -2.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1024.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1024.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_roundevenf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c new file mode 100644 index 00000000000..b1918bad45e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-1.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +float in[ARRAY_SIZE]; +float out[ARRAY_SIZE]; +float ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (float, __builtin_roundf) +TEST_ASSERT (float) + +TEST_INIT (float, 1.2, 1.0, 1) +TEST_INIT (float, -1.5, -2.0, 2) +TEST_INIT (float, 3.0, 3.0, 3) +TEST_INIT (float, 8388607.5, 8388608.0, 4) +TEST_INIT (float, 8388609.0, 8388609.0, 5) +TEST_INIT (float, 0.0, 0.0, 6) +TEST_INIT (float, -0.0, -0.0, 7) +TEST_INIT (float, -8388607.5, -8388608.0, 8) +TEST_INIT (float, -8388608.0, -8388608.0, 9) + +int +main () +{ + RUN_TEST (float, 1, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 2, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 3, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 4, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 5, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 6, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 7, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 8, __builtin_roundf, in, out, ref, ARRAY_SIZE); + RUN_TEST (float, 9, __builtin_roundf, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c new file mode 100644 index 00000000000..9f037b4c908 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-roundeven-run-2.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +double in[ARRAY_SIZE]; +double out[ARRAY_SIZE]; +double ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (double, __builtin_round) +TEST_ASSERT (double) + +TEST_INIT (double, 1.2, 1.0, 1) +TEST_INIT (double, -1.5, -2.0, 2) +TEST_INIT (double, 3.0, 3.0, 3) +TEST_INIT (double, 4503599627370495.5, 4503599627370496.0, 4) +TEST_INIT (double, 4503599627370497.0, 4503599627370497.0, 5) +TEST_INIT (double, 0.0, 0.0, 6) +TEST_INIT (double, -0.0, -0.0, 7) +TEST_INIT (double, -4503599627370495.5, -4503599627370496.0, 8) +TEST_INIT (double, -4503599627370496.0, -4503599627370496.0, 9) + +int +main () +{ + RUN_TEST (double, 1, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 2, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 3, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 4, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 5, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 6, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 7, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 8, __builtin_round, in, out, ref, ARRAY_SIZE); + RUN_TEST (double, 9, __builtin_round, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c new file mode 100644 index 00000000000..340acb5994c --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-trunc-run-0.c @@ -0,0 +1,39 @@ +/* { dg-do run { target { riscv_v } } } */ +/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */ + +#include "test-math.h" + +#define ARRAY_SIZE 128 + +_Float16 in[ARRAY_SIZE]; +_Float16 out[ARRAY_SIZE]; +_Float16 ref[ARRAY_SIZE]; + +TEST_UNARY_CALL (_Float16, __builtin_truncf16) +TEST_ASSERT (_Float16) + +TEST_INIT (_Float16, 1.2, 1.0, 1) +TEST_INIT (_Float16, -1.2, -1.0, 2) +TEST_INIT (_Float16, 3.0, 3.0, 3) +TEST_INIT (_Float16, 1023.5, 1023.0, 4) +TEST_INIT (_Float16, 1024.0, 1024.0, 5) +TEST_INIT (_Float16, 0.0, 0.0, 6) +TEST_INIT (_Float16, -0.0, -0.0, 7) +TEST_INIT (_Float16, -1023.5, -1023.0, 8) +TEST_INIT (_Float16, -1024.0, -1024.0, 9) + +int +main () +{ + RUN_TEST (_Float16, 1, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 2, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 3, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 4, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 5, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 6, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 7, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 8, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + RUN_TEST (_Float16, 9, __builtin_truncf16, in, out, ref, ARRAY_SIZE); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp index ff76e17d0e6..87d3e8f9a06 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp +++ b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp @@ -30,10 +30,10 @@ if ![info exists DEFAULT_CFLAGS] then { set DEFAULT_CFLAGS " -ansi -pedantic-errors" } -set gcc_march "rv64gcv_zfh" +set gcc_march "rv64gcv_zfa_zfh" set gcc_mabi "lp64d" if [istarget riscv32-*-*] then { - set gcc_march "rv32gcv_zfh" + set gcc_march "rv32gcv_zfa_zfh" set gcc_mabi "ilp32d" }