--- /dev/null
+#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
/* { 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:
/* { 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:
/* { 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:
/* { 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:
/* { 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
/* { 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
/* { 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
/* { 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
/* { 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:
/* { 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:
/* { 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:
/* { 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:
/* { 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
/* { 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
/* { 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
/* { 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
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)
#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) */
/******************************************************************************/
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) \
#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