From: Pan Li <pan2...@intel.com>

Refine the run test case to avoid interactive checking in RV32, by
separating each checks in different functions.

Signed-off-by: Pan Li <pan2...@intel.com>

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/rvv/base/float-point-frm-run-1.c: Fix failure
        on RV32.
---
 .../riscv/rvv/base/float-point-frm-run-1.c    | 58 ++++++++++---------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-run-1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-run-1.c
index 210c49c5e8d..1d90b4f50d9 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-run-1.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/float-point-frm-run-1.c
@@ -5,6 +5,24 @@
 #include <stdio.h>
 #include <stdint-gcc.h>
 
+#define DEFINE_TEST_FRM_FUNC(FRM) \
+vfloat32m1_t __attribute__ ((noinline)) \
+test_float_point_frm_run_##FRM (vfloat32m1_t op1, vfloat32m1_t op2, size_t vl) 
\
+{                                                                              
\
+  vfloat32m1_t result;                                                         
\
+                                                                               
\
+  set_frm (0);                                                                 
\
+                                                                               
\
+  result = __riscv_vfadd_vv_f32m1_rm (op1, result, FRM, vl);                   
\
+                                                                               
\
+  assert_equal (FRM, get_frm (), "The value of frm should be " #FRM ".");      
\
+                                                                               
\
+  return result;                                                               
\
+}
+
+#define CALL_TEST_FUNC(FRM, op1, op2, vl) \
+  test_float_point_frm_run_##FRM (op1, op2, vl)
+
 static int
 get_frm ()
 {
@@ -31,40 +49,22 @@ set_frm (int frm)
   );
 }
 
-static inline void
+void __attribute__ ((noinline)) \
 assert_equal (int a, int b, char *message)
 {
   if (a != b)
     {
-      printf (message);
+      fprintf (stdout, message);
+      fflush (stdout);
       __builtin_abort ();
     }
 }
 
-vfloat32m1_t __attribute__ ((noinline))
-test_float_point_frm_run (vfloat32m1_t op1, vfloat32m1_t op2, size_t vl)
-{
-  set_frm (0);
-
-  vfloat32m1_t result;
-
-  result = __riscv_vfadd_vv_f32m1_rm (op1, result, 1, vl);
-  assert_equal (1, get_frm (), "The value of frm register should be 1.");
-
-  result = __riscv_vfadd_vv_f32m1_rm (op1, result, 2, vl);
-  assert_equal (2, get_frm (), "The value of frm register should be 2.");
-
-  result = __riscv_vfadd_vv_f32m1_rm (op1, result, 3, vl);
-  assert_equal (3, get_frm (), "The value of frm register should be 3.");
-
-  result = __riscv_vfadd_vv_f32m1_rm (op1, result, 4, vl);
-  assert_equal (4, get_frm (), "The value of frm register should be 4.");
-
-  result = __riscv_vfadd_vv_f32m1_rm (op1, result, 0, vl);
-  assert_equal (0, get_frm (), "The value of frm register should be 0.");
-
-  return result;
-}
+DEFINE_TEST_FRM_FUNC (0)
+DEFINE_TEST_FRM_FUNC (1)
+DEFINE_TEST_FRM_FUNC (2)
+DEFINE_TEST_FRM_FUNC (3)
+DEFINE_TEST_FRM_FUNC (4)
 
 int
 main ()
@@ -73,7 +73,11 @@ main ()
   vfloat32m1_t op1;
   vfloat32m1_t op2;
 
-  test_float_point_frm_run (op1, op2, vl);
+  CALL_TEST_FUNC (0, op1, op2, vl);
+  CALL_TEST_FUNC (1, op1, op2, vl);
+  CALL_TEST_FUNC (2, op1, op2, vl);
+  CALL_TEST_FUNC (3, op1, op2, vl);
+  CALL_TEST_FUNC (4, op1, op2, vl);
 
   return 0;
 }
-- 
2.34.1

Reply via email to