]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Refine the SAT_ARITH test help header files [NFC]
authorPan Li <pan2.li@intel.com>
Sat, 15 Jun 2024 02:15:17 +0000 (10:15 +0800)
committerPan Li <pan2.li@intel.com>
Sat, 15 Jun 2024 09:50:38 +0000 (17:50 +0800)
Separate the vector part code to one standalone header file,  which
is independent with the scalar part.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c: Leverage
the new header file for vector part.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-4.c: Ditto.
* gcc.target/riscv/sat_arith.h: Move vector part out.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
18 files changed:
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-3.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-4.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-1.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-2.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-3.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-4.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-1.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-2.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-3.c
gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_sub-run-4.c
gcc/testsuite/gcc.target/riscv/sat_arith.h

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_arith.h
new file mode 100644 (file)
index 0000000..450f0fb
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef HAVE_VEC_SAT_ARITH
+#define HAVE_VEC_SAT_ARITH
+
+#include <stdint-gcc.h>
+
+/******************************************************************************/
+/* Saturation Add (unsigned and signed)                                       */
+/******************************************************************************/
+#define DEF_VEC_SAT_U_ADD_FMT_1(T)                                   \
+void __attribute__((noinline))                                       \
+vec_sat_u_add_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \
+{                                                                    \
+  unsigned i;                                                        \
+  for (i = 0; i < limit; i++)                                        \
+    {                                                                \
+      T x = op_1[i];                                                 \
+      T y = op_2[i];                                                 \
+      out[i] = (x + y) | (-(T)((T)(x + y) < x));                     \
+    }                                                                \
+}
+
+#define RUN_VEC_SAT_U_ADD_FMT_1(T, out, op_1, op_2, N) \
+  vec_sat_u_add_##T##_fmt_1(out, op_1, op_2, N)
+
+/******************************************************************************/
+/* Saturation Sub (Unsigned and Signed)                                       */
+/******************************************************************************/
+#define DEF_VEC_SAT_U_SUB_FMT_1(T)                                   \
+void __attribute__((noinline))                                       \
+vec_sat_u_sub_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \
+{                                                                    \
+  unsigned i;                                                        \
+  for (i = 0; i < limit; i++)                                        \
+    {                                                                \
+      T x = op_1[i];                                                 \
+      T y = op_2[i];                                                 \
+      out[i] = (x - y) & (-(T)(x >= y));                             \
+    }                                                                \
+}
+
+#define DEF_VEC_SAT_U_SUB_FMT_2(T)                                   \
+void __attribute__((noinline))                                       \
+vec_sat_u_sub_##T##_fmt_2 (T *out, T *op_1, T *op_2, unsigned limit) \
+{                                                                    \
+  unsigned i;                                                        \
+  for (i = 0; i < limit; i++)                                        \
+    {                                                                \
+      T x = op_1[i];                                                 \
+      T y = op_2[i];                                                 \
+      out[i] = (x - y) & (-(T)(x > y));                              \
+    }                                                                \
+}
+
+#define RUN_VEC_SAT_U_SUB_FMT_1(T, out, op_1, op_2, N) \
+  vec_sat_u_sub_##T##_fmt_1(out, op_1, op_2, N)
+#define RUN_VEC_SAT_U_SUB_FMT_2(T, out, op_1, op_2, N) \
+  vec_sat_u_sub_##T##_fmt_2(out, op_1, op_2, N)
+
+#endif
index dbbfa00afe2b6474fe8c16b5bca78f54b2f44f8a..6fe84f3945fee0aa8606d37436ddc1c93550d694 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_add_uint8_t_fmt_1:
index 1253fdb5f600340b9c072bc80b09c764277f773d..e9a40e0dcd049369aee3211bd9a572ca165d75bf 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_add_uint16_t_fmt_1:
index 74bba9cadd11cdd100b076c6edfb06ba48861a0a..f30000698a2f70bcfcccff1849b922aa375bd4e8 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_add_uint32_t_fmt_1:
index f3692b4cc2534665ded731106e40131aa9530436..9c9ba2797d04fbccef109c819c4a5580f7393f18 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_add_uint64_t_fmt_1:
index 1dcb333f687addcff809d55bc118ddbc4406e9df..151bc466c72bf6365a56302ad6c421e0ad203d92 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint8_t
 #define N                  16
index dbf01ac863df20c7728f78e9b16a9739d785488e..4d545226b2b0c3d519e4c96f62e5342d7db5f6d3 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint16_t
 #define N                  16
index 20ad2736403efbad546ba69cee8dd246edbbad0e..f1b3a4fc79ebe6b7fcd1074ce97e45c0a0af7077 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint32_t
 #define N                  16
index 2f31edc527edf57fa8246b62bd294cac04e14dea..4768d6283c6bba43c8a4d22db2f9514a8d3954af 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint64_t
 #define N                  16
index 1e6e323012dae2bdb439f7d8731b58c04c381376..ff444ea3862171cd8257f35060fcee2052f0efea 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_sub_uint8_t_fmt_1:
index 9c5705650486cfdb6857cae2d2764d8e6822b312..2bde6a23ead012fa451ee48a58014cc583868d85 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_sub_uint16_t_fmt_1:
index 795d5ff5c70557168d84be830a5a9ea5df2a6f85..ab688fcde9618ca199b4c8f1d0c1de4003fd7992 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_sub_uint32_t_fmt_1:
index 00527c6800318073faeba7138ba9ac6eabd3c4ed..8bcca4fa474e7e3fecd6872a59d441e56abbf622 100644 (file)
@@ -3,7 +3,7 @@
 /* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 /*
 ** vec_sat_u_sub_uint64_t_fmt_1:
index 4f6b7927f19c015d89b0a2fb2a59b55596c08edb..b6c48388cf82dffff4f570b4a669934b88033ae0 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint8_t
 #define N                  16
index 8b115ea6ec3d0c6bd9ffc629a04cdc58619dd8de..18b53fd2df94c528e30fda2b8a6085bec63fb21b 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint16_t
 #define N                  16
index aa47ef7ce80cc043da46d6998e632f671c161585..527a95b9a9f972afec3bafafdc97c89263c8e30b 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint32_t
 #define N                  16
index 91daf3a7c1a50a7878fc34d65f042258e18b3486..b78fd824acd52fcb4887f5f769b11d816b094ab0 100644 (file)
@@ -1,7 +1,7 @@
 /* { dg-do run { target { riscv_v } } } */
 /* { dg-additional-options "-std=c99" } */
 
-#include "../../../sat_arith.h"
+#include "vec_sat_arith.h"
 
 #define T                  uint64_t
 #define N                  16
index 4c02783e845733c3979aaf8e626fe05d76a36618..0f94c5ff087b0ef641fad48d9b15fdd744a34fa8 100644 (file)
@@ -52,19 +52,6 @@ sat_u_add_##T##_fmt_6 (T x, T y)        \
   return (T)(x + y) < x ? -1 : (x + y); \
 }
 
-#define DEF_VEC_SAT_U_ADD_FMT_1(T)                                   \
-void __attribute__((noinline))                                       \
-vec_sat_u_add_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \
-{                                                                    \
-  unsigned i;                                                        \
-  for (i = 0; i < limit; i++)                                        \
-    {                                                                \
-      T x = op_1[i];                                                 \
-      T y = op_2[i];                                                 \
-      out[i] = (x + y) | (-(T)((T)(x + y) < x));                     \
-    }                                                                \
-}
-
 #define RUN_SAT_U_ADD_FMT_1(T, x, y) sat_u_add_##T##_fmt_1(x, y)
 #define RUN_SAT_U_ADD_FMT_2(T, x, y) sat_u_add_##T##_fmt_2(x, y)
 #define RUN_SAT_U_ADD_FMT_3(T, x, y) sat_u_add_##T##_fmt_3(x, y)
@@ -72,9 +59,6 @@ vec_sat_u_add_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \
 #define RUN_SAT_U_ADD_FMT_5(T, x, y) sat_u_add_##T##_fmt_5(x, y)
 #define RUN_SAT_U_ADD_FMT_6(T, x, y) sat_u_add_##T##_fmt_6(x, y)
 
-#define RUN_VEC_SAT_U_ADD_FMT_1(T, out, op_1, op_2, N) \
-  vec_sat_u_add_##T##_fmt_1(out, op_1, op_2, N)
-
 /******************************************************************************/
 /* Saturation Sub (Unsigned and Signed)                                       */
 /******************************************************************************/
@@ -92,11 +76,11 @@ sat_u_sub_##T##_fmt_2 (T x, T y)  \
   return (x - y) & (-(T)(x > y)); \
 }
 
-#define DEF_SAT_U_SUB_FMT_3(T)    \
-T __attribute__((noinline))       \
-sat_u_sub_##T##_fmt_3 (T x, T y)  \
-{                                 \
-  return x > y ? x - y : 0;       \
+#define DEF_SAT_U_SUB_FMT_3(T)   \
+T __attribute__((noinline))      \
+sat_u_sub_##T##_fmt_3 (T x, T y) \
+{                                \
+  return x > y ? x - y : 0;      \
 }
 
 #define DEF_SAT_U_SUB_FMT_4(T)   \
@@ -167,35 +151,4 @@ sat_u_sub_##T##_fmt_10 (T x, T y)                   \
 #define RUN_SAT_U_SUB_FMT_9(T, x, y) sat_u_sub_##T##_fmt_9(x, y)
 #define RUN_SAT_U_SUB_FMT_10(T, x, y) sat_u_sub_##T##_fmt_10(x, y)
 
-#define DEF_VEC_SAT_U_SUB_FMT_1(T)                                   \
-void __attribute__((noinline))                                       \
-vec_sat_u_sub_##T##_fmt_1 (T *out, T *op_1, T *op_2, unsigned limit) \
-{                                                                    \
-  unsigned i;                                                        \
-  for (i = 0; i < limit; i++)                                        \
-    {                                                                \
-      T x = op_1[i];                                                 \
-      T y = op_2[i];                                                 \
-      out[i] = (x - y) & (-(T)(x >= y));                             \
-    }                                                                \
-}
-
-#define DEF_VEC_SAT_U_SUB_FMT_2(T)                                   \
-void __attribute__((noinline))                                       \
-vec_sat_u_sub_##T##_fmt_2 (T *out, T *op_1, T *op_2, unsigned limit) \
-{                                                                    \
-  unsigned i;                                                        \
-  for (i = 0; i < limit; i++)                                        \
-    {                                                                \
-      T x = op_1[i];                                                 \
-      T y = op_2[i];                                                 \
-      out[i] = (x - y) & (-(T)(x > y));                              \
-    }                                                                \
-}
-
-#define RUN_VEC_SAT_U_SUB_FMT_1(T, out, op_1, op_2, N) \
-  vec_sat_u_sub_##T##_fmt_1(out, op_1, op_2, N)
-#define RUN_VEC_SAT_U_SUB_FMT_2(T, out, op_1, op_2, N) \
-  vec_sat_u_sub_##T##_fmt_2(out, op_1, op_2, N)
-
 #endif