LGTM juzhe.zhong@rivai.ai From: Robin Dapp Date: 2023-08-15 23:49 To: gcc-patches; palmer; Kito Cheng; jeffreyalaw; juzhe.zhong@rivai.ai CC: rdapp.gcc Subject: [PATCH] RISC-V: Fix reduc_strict_run-1 test case. Hi, this patch changes the equality check for the reduc_strict_run-1 testcase from == to fabs () < EPS. The FAIL only occurs with _Float16 but I'd argue approximate equality is preferable for all float modes. Regards Robin gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c: Check float equality with fabs < EPS. --- .../riscv/rvv/autovec/reduc/reduc_strict_run-1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c index 516be97e9eb..93efe2c4333 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/reduc/reduc_strict_run-1.c @@ -2,6 +2,9 @@ /* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model" } */ #include "reduc_strict-1.c" +#include + +#define EPS 1e-2 #define TEST_REDUC_PLUS(TYPE) \ { \ @@ -10,14 +13,14 @@ TYPE r = 0, q = 3; \ for (int i = 0; i < NUM_ELEMS (TYPE); i++) \ { \ - a[i] = (i * 0.1) * (i & 1 ? 1 : -1); \ - b[i] = (i * 0.3) * (i & 1 ? 1 : -1); \ + a[i] = (i * 0.01) * (i & 1 ? 1 : -1); \ + b[i] = (i * 0.03) * (i & 1 ? 1 : -1); \ r += a[i]; \ q -= b[i]; \ asm volatile ("" ::: "memory"); \ } \ TYPE res = reduc_plus_##TYPE (a, b); \ - if (res != r * q) \ + if (fabs (res - r * q) > EPS) \ __builtin_abort (); \ } -- 2.41.0