-/* { dg-do run { target { riscv_zvfh } } } */
-/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-signaling-nans" } */
+/* { dg-do compile } */
+/* { dg-additional-options "-march=rv32gcv_zvfh -mabi=ilp32d --param=riscv-autovec-preference=scalable --param vect-epilogues-nomask=0 -fno-signaling-nans" } */
#include <stdint-gcc.h>
#define FN(X) __builtin_fmax##X
#endif
-#define DEF_LOOP(FN, SUFFIX, TYPE) \
+#define DEF_LOOP(FN, SUFFIX, TYPE) \
void __attribute__ ((noipa)) \
test_##TYPE (TYPE *__restrict x, TYPE *__restrict y, int n) \
{ \
for (int i = 0; i < n; ++i) \
- x[i] = FN (SUFFIX) (x[i], y[i]); \
+ x[i] = FN (SUFFIX) (x[i], y[i]); \
}
-#define TEST_ALL(T) \
- T (FN, f16, _Float16) \
+#define TEST_ALL(T) T (FN, f16, _Float16)
TEST_ALL (DEF_LOOP)
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-signaling-nans" } */
#include <math.h>
dst[7] = nan ("0.0"); \
dst[8] = INFINITY; \
dst[9] = -INFINITY; \
- kest_##TYPE (dst, y, N); \
+ test_##TYPE (dst, y, N); \
for (int i = 0; i < N; ++i) \
{ \
double ref = FN (SUFFIX) (x[i], y[i]); \
#include "fmax_zvfh-1.c"
/* { dg-final { scan-assembler-times {vfmin\.vv\s+v[0-9]+,v[0-9]+,v[0-9]+} 1 } } */
-
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-signaling-nans" } */
#define FN(X) __builtin_fmin##X
/* FP -> INT */
#define TEST_ALL_F2X_SAME(T) \
- T (_Float16, uint16_t) \
- T (_Float16, int16_t) \
T (float, uint32_t) \
T (float, int32_t) \
T (double, uint64_t) \
/* FP -> wider-INT */
#define TEST_ALL_F2X_WIDER(T) \
- T (_Float16, uint32_t) \
- T (_Float16, int32_t) \
- T (_Float16, uint64_t) \
- T (_Float16, int64_t) \
T (float, uint64_t) \
T (float, int64_t)
/* FP -> narrower-INT */
#define TEST_ALL_F2X_NARROWER(T) \
- T (_Float16, uint8_t) \
- T (_Float16, int8_t) \
T (float, uint8_t) \
T (float, int8_t) \
T (float, uint16_t) \
/* FP -> INT */
#define TEST_ALL_F2X_SAME(T) \
- T (_Float16, uint16_t) \
- T (_Float16, int16_t) \
T (float, uint32_t) \
T (float, int32_t) \
T (double, uint64_t) \
/* FP -> wider-INT */
#define TEST_ALL_F2X_WIDER(T) \
- T (_Float16, uint32_t) \
- T (_Float16, int32_t) \
- T (_Float16, uint64_t) \
- T (_Float16, int64_t) \
T (float, uint64_t) \
T (float, int64_t)
/* FP -> narrower-INT */
#define TEST_ALL_F2X_NARROWER(T) \
- T (_Float16, uint8_t) \
- T (_Float16, int8_t) \
T (float, uint8_t) \
T (float, int8_t) \
T (float, uint16_t) \
#include "cond_convert_float2int-1.h"
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+\n} 6 } } */
/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
#include "cond_convert_float2int-2.h"
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+\n} 6 } } */
/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
#include "cond_convert_float2int-1.h"
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+\n} 6 } } */
/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
#include "cond_convert_float2int-2.h"
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
-/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
-/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 3 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 2 } } */
/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+\n} 6 } } */
/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
OLD_TYPE a[N], pred[N]; \
for (int i = 0; i < N; ++i) \
{ \
- a[i] = (i & 1 ? i : 3 * i) * (i % 3 == 0 ? 1 : -1); \
+ a[i] = (i & 1 ? i : 1.1 * i) * (i % 3 == 0 ? 1.2 : -1.5); \
b[i] = (i % 9) * (i % 7 + 1); \
pred[i] = (i % 7 < 4); \
- asm volatile("" ::: "memory"); \
+ asm volatile ("" ::: "memory"); \
} \
test_##OLD_TYPE##_2_##NEW_TYPE (r, a, b, pred, N); \
for (int i = 0; i < N; ++i) \
- if (r[i] != (pred[i] ? (NEW_TYPE) a[i] : b[i])) \
- __builtin_abort (); \
+ { \
+ NEW_TYPE ref = pred[i] ? a[i] : b[i]; \
+ if (r[i] != ref) \
+ __builtin_abort (); \
+ } \
}
int
OLD_TYPE a[N], pred[N]; \
for (int i = 0; i < N; ++i) \
{ \
- a[i] = (i & 1 ? i : 3 * i) * (i % 3 == 0 ? 1 : -1); \
+ a[i] = (i & 1 ? i : 1.2 * i) * (i % 3 == 0 ? 1 : -1); \
pred[i] = (i % 7 < 4); \
asm volatile("" ::: "memory"); \
} \
--- /dev/null
+#include <stdint-gcc.h>
+
+#define DEF_LOOP(OLD_TYPE, NEW_TYPE) \
+ void __attribute__ ((noipa)) \
+ test_##OLD_TYPE##_2_##NEW_TYPE (NEW_TYPE *__restrict r, \
+ OLD_TYPE *__restrict a, \
+ NEW_TYPE *__restrict b, \
+ OLD_TYPE *__restrict pred, int n) \
+ { \
+ for (int i = 0; i < n; ++i) \
+ { \
+ r[i] = pred[i] ? (NEW_TYPE) a[i] : b[i]; \
+ } \
+ }
+
+/* FP -> INT */
+#define TEST_ALL_F2X_SAME(T) \
+ T (_Float16, uint16_t) \
+ T (_Float16, int16_t) \
+
+/* FP -> wider-INT */
+#define TEST_ALL_F2X_WIDER(T) \
+ T (_Float16, uint32_t) \
+ T (_Float16, int32_t) \
+ T (_Float16, uint64_t) \
+ T (_Float16, int64_t) \
+
+/* FP -> narrower-INT */
+#define TEST_ALL_F2X_NARROWER(T) \
+ T (_Float16, uint8_t) \
+ T (_Float16, int8_t) \
+
+TEST_ALL_F2X_SAME (DEF_LOOP)
+TEST_ALL_F2X_WIDER (DEF_LOOP)
+TEST_ALL_F2X_NARROWER (DEF_LOOP)
--- /dev/null
+#include <stdint-gcc.h>
+
+#define DEF_LOOP(OLD_TYPE, NEW_TYPE) \
+ void __attribute__ ((noipa)) \
+ test_##OLD_TYPE##_2_##NEW_TYPE (NEW_TYPE *__restrict r, \
+ OLD_TYPE *__restrict a, NEW_TYPE b, \
+ OLD_TYPE *__restrict pred, int n) \
+ { \
+ for (int i = 0; i < n; ++i) \
+ { \
+ r[i] = pred[i] ? (NEW_TYPE) a[i] : b; \
+ } \
+ }
+
+/* FP -> INT */
+#define TEST_ALL_F2X_SAME(T) \
+ T (_Float16, uint16_t) \
+ T (_Float16, int16_t) \
+
+/* FP -> wider-INT */
+#define TEST_ALL_F2X_WIDER(T) \
+ T (_Float16, uint32_t) \
+ T (_Float16, int32_t) \
+ T (_Float16, uint64_t) \
+ T (_Float16, int64_t) \
+
+/* FP -> narrower-INT */
+#define TEST_ALL_F2X_NARROWER(T) \
+ T (_Float16, uint8_t) \
+ T (_Float16, int8_t) \
+
+TEST_ALL_F2X_SAME (DEF_LOOP)
+TEST_ALL_F2X_WIDER (DEF_LOOP)
+TEST_ALL_F2X_NARROWER (DEF_LOOP)
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-march=rv32gcv_zvfh -mabi=ilp32d --param riscv-autovec-preference=scalable -fno-vect-cost-model -ffast-math" } */
+
+#include "cond_convert_float2int_zvfh-1.h"
+
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
+/* { dg-final { scan-assembler-not {\tvf?merge\.v[vxi]m\t} } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-march=rv32gcv_zvfh -mabi=ilp32d --param riscv-autovec-preference=scalable -fno-vect-cost-model -ffast-math" } */
+
+#include "cond_convert_float2int_zvfh-2.h"
+
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
+/* { dg-final { scan-assembler-not {\tvf?merge\.v[vxi]m\t} } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-march=rv64gcv_zvfh -mabi=lp64d --param riscv-autovec-preference=scalable -fno-vect-cost-model -ffast-math" } */
+
+#include "cond_convert_float2int_zvfh-1.h"
+
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
+/* { dg-final { scan-assembler-not {\tvf?merge\.v[vxi]m\t} } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-march=rv64gcv_zvfh -mabi=lp64d --param riscv-autovec-preference=scalable -fno-vect-cost-model -ffast-math" } */
+
+#include "cond_convert_float2int_zvfh-2.h"
+
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.xu\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfwcvt\.rtz\.x\.f\.v\tv[0-9]+,v[0-9]+\n} 2 } } */
+
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.xu\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+/* { dg-final { scan-assembler-times {\tvfncvt\.rtz\.x\.f\.w\tv[0-9]+,v[0-9]+,v0\.t} 1 } } */
+
+/* { dg-final { scan-assembler {\tvsetvli\t[a-z0-9]+,[a-z0-9]+,e[0-9]+,m[f0-9]+,t[au],mu} } } */
+/* { dg-final { scan-assembler-not {\tvf?merge\.v[vxi]m\t} } } */
--- /dev/null
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
+/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model" } */
+
+#include "cond_convert_float2int_zvfh-1.h"
+
+#define N 77
+
+#define TEST_LOOP(OLD_TYPE, NEW_TYPE) \
+ { \
+ NEW_TYPE r[N], b[N]; \
+ OLD_TYPE a[N], pred[N]; \
+ for (int i = 0; i < N; ++i) \
+ { \
+ a[i] = (i & 1 ? i : 1.1 * i) * (i % 3 == 0 ? 1.2 : -1.5); \
+ b[i] = (i % 9) * (i % 7 + 1); \
+ pred[i] = (i % 7 < 4); \
+ asm volatile ("" ::: "memory"); \
+ } \
+ test_##OLD_TYPE##_2_##NEW_TYPE (r, a, b, pred, N); \
+ for (int i = 0; i < N; ++i) \
+ { \
+ NEW_TYPE ref = pred[i] ? a[i] : b[i]; \
+ if (r[i] != ref) \
+ __builtin_abort (); \
+ } \
+ }
+
+int
+main ()
+{
+ TEST_ALL_F2X_SAME (TEST_LOOP)
+ TEST_ALL_F2X_WIDER (TEST_LOOP)
+ TEST_ALL_F2X_NARROWER (TEST_LOOP)
+ return 0;
+}
--- /dev/null
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
+/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model" } */
+
+#include "cond_convert_float2int_zvfh-2.h"
+
+#define N 77
+
+#define TEST_LOOP(OLD_TYPE, NEW_TYPE) \
+ { \
+ NEW_TYPE r[N], b = 192; \
+ OLD_TYPE a[N], pred[N]; \
+ for (int i = 0; i < N; ++i) \
+ { \
+ a[i] = (i & 1 ? i : 1.2 * i) * (i % 3 == 0 ? 1 : -1); \
+ pred[i] = (i % 7 < 4); \
+ asm volatile("" ::: "memory"); \
+ } \
+ test_##OLD_TYPE##_2_##NEW_TYPE (r, a, b, pred, N); \
+ for (int i = 0; i < N; ++i) \
+ if (r[i] != (pred[i] ? (NEW_TYPE) a[i] : b)) \
+ __builtin_abort (); \
+ }
+
+int
+main ()
+{
+ TEST_ALL_F2X_SAME (TEST_LOOP)
+ TEST_ALL_F2X_WIDER (TEST_LOOP)
+ TEST_ALL_F2X_NARROWER (TEST_LOOP)
+ return 0;
+}
#define N 99
+#define EPS 1e-8
+
#define TEST_LOOP(OLD_TYPE, NEW_TYPE) \
{ \
NEW_TYPE r[N], b[N]; \
a[i] = (i & 1 ? i : 3 * i) * (i % 3 == 0 ? 1 : -1); \
b[i] = (i % 9) * (i % 7 + 1); \
pred[i] = (i % 7 < 4); \
- asm volatile("" ::: "memory"); \
+ asm volatile ("" ::: "memory"); \
} \
test_##OLD_TYPE##_2_##NEW_TYPE (r, a, b, pred, N); \
for (int i = 0; i < N; ++i) \
- if (r[i] != (pred[i] ? (NEW_TYPE) a[i] : b[i])) \
- __builtin_abort (); \
+ { \
+ NEW_TYPE ref = pred[i] ? a[i] : b[i]; \
+ if (__builtin_fabsf (r[i] - ref) > EPS) \
+ __builtin_abort (); \
+ } \
}
int
#define N 99
+#define EPS 1e-8
+
#define TEST_LOOP(OLD_TYPE, NEW_TYPE) \
{ \
NEW_TYPE r[N], b = 192.12; \
{ \
a[i] = (i & 1 ? i : 3 * i) * (i % 3 == 0 ? 1 : -1); \
pred[i] = (i % 7 < 4); \
- asm volatile("" ::: "memory"); \
+ asm volatile ("" ::: "memory"); \
} \
test_##OLD_TYPE##_2_##NEW_TYPE (r, a, b, pred, N); \
for (int i = 0; i < N; ++i) \
- if (r[i] != (pred[i] ? (NEW_TYPE) a[i] : b)) \
- __builtin_abort (); \
+ { \
+ NEW_TYPE ref = pred[i] ? a[i] : b; \
+ if (__builtin_fabsf (r[i] - ref) > EPS) \
+ __builtin_abort (); \
+ } \
}
int
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#include "cond_fmax_zvfh-1.c"
test_##TYPE##_##NAME (x, y, pred, N); \
for (int i = 0; i < N; ++i) \
{ \
- TYPE expected = i % 3 != 1 ? FN (y[i], CONST) : y[i]; \
+ TYPE expected = i % 3 != 1 ? FN (y[i], CONST) : y[i]; \
if (x[i] != expected) \
__builtin_abort (); \
asm volatile ("" ::: "memory"); \
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#include "cond_fmax_zvfh-2.c"
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#include "cond_fmax_zvfh-3.c"
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#include "cond_fmax_zvfh-4.c"
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#define FN(X) __builtin_fmin##X
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#define FN(X) __builtin_fmin##X
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#define FN(X) __builtin_fmin##X
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-vect-cost-model -fno-signaling-nans" } */
#define FN(X) __builtin_fmin##X
/* { dg-additional-options "--param riscv-autovec-preference=scalable -fno-vect-cost-model -ffast-math " } */
#include "cond_sqrt-zvfh-1.c"
-#include <stdio.h>
#define N 99
+#define EPS 1e-2
+
#define TEST_LOOP(TYPE, OP) \
{ \
TYPE r[N], a[N], pred[N]; \
{ \
a[i] = (i & 1 ? i : 3 * i) * (i % 3 == 0 ? 1 : 2); \
pred[i] = (i % 7 < 4); \
- asm volatile("" ::: "memory"); \
+ asm volatile ("" ::: "memory"); \
} \
test_##TYPE##_##OP (r, a, pred, N); \
for (int i = 0; i < N; ++i) \
- if (r[i] != (pred[i] ? OP (a[i]) : a[i])) \
- __builtin_abort (); \
+ { \
+ float ref = pred[i] ? __builtin_sqrtf (a[i]) : a[i]; \
+ if (__builtin_fabsf (r[i] - ref) > EPS) \
+ __builtin_abort (); \
+ } \
}
int
#define N 99
+#define EPS 1e-2
+
#define TEST_LOOP(TYPE, OP) \
{ \
TYPE r[N], a[N], b[N], pred[N]; \
a[i] = (i & 1 ? i : 3 * i) * (i % 3 == 0 ? 1 : 2); \
b[i] = (i % 9) * (i % 7 + 1); \
pred[i] = (i % 7 < 4); \
- asm volatile("" ::: "memory"); \
+ asm volatile ("" ::: "memory"); \
} \
test_##TYPE##_##OP (r, a, b, pred, N); \
for (int i = 0; i < N; ++i) \
- if (r[i] != (pred[i] ? OP (a[i]) : b[i])) \
- __builtin_abort (); \
+ { \
+ float ref = pred[i] ? __builtin_sqrtf (a[i]) : b[i]; \
+ if (__builtin_fabsf (r[i] - ref) > EPS) \
+ __builtin_abort (); \
+ } \
}
int
TYPE __attribute__ ((noinline, noclone)) \
reduc_##NAME##_##TYPE (TYPE *a, int n) \
{ \
- TYPE r = -0.0; \
+ TYPE r = -0.0; \
for (int i = 0; i < n; ++i) \
r = MAXMIN_OP (r, a[i]); \
return r; \
}
#define TEST_FMAXMIN(T) \
- T (_Float16, max, __builtin_fmaxf16) \
- T (_Float16, min, __builtin_fminf16) \
-
+ T (_Float16, max, __builtin_fmaxf16) \
+ T (_Float16, min, __builtin_fminf16)
TEST_FMAXMIN (DEF_REDUC_FMAXMIN)
-/* { dg-do run { target { riscv_zvfh } } } */
+/* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
/* { dg-additional-options "--param=riscv-autovec-preference=scalable -fno-signaling-nans" } */
#include <math.h>
#define NUM_ELEMS(TYPE) (73 + sizeof (TYPE))
-#define INIT_VECTOR(TYPE) \
- TYPE a[NUM_ELEMS (TYPE) + 1]; \
- for (int i = 0; i < NUM_ELEMS (TYPE) + 1; i++) \
- { \
- a[i] = ((i * 2) * (i & 1 ? 1 : -1) | 3); \
- asm volatile ("" ::: "memory"); \
- } \
- a[0] = -0.0; \
- a[1] = nan ("0.0"); \
- a[2] = nan ("1.0"); \
- a[3] = 0.0; \
- a[4] = -INFINITY; \
- a[5] = INFINITY; \
+#define INIT_VECTOR(TYPE) \
+ TYPE a[NUM_ELEMS (TYPE) + 1]; \
+ for (int i = 0; i < NUM_ELEMS (TYPE) + 1; i++) \
+ { \
+ a[i] = ((i * 2) * (i & 1 ? 1 : -1) | 3); \
+ asm volatile ("" ::: "memory"); \
+ } \
+ a[0] = -0.0; \
+ a[1] = nan ("0.0"); \
+ a[2] = nan ("1.0"); \
+ a[3] = 0.0; \
+ a[4] = -INFINITY; \
+ a[5] = INFINITY;\
-#define TEST_REDUC_FMAXMIN(TYPE, NAME, MAXMIN_OP) \
- { \
- INIT_VECTOR (TYPE); \
- TYPE r1 = reduc_##NAME##_##TYPE (a, NUM_ELEMS (TYPE)); \
- volatile TYPE r2 = -0.0; \
- for (int i = 0; i < NUM_ELEMS (TYPE); ++i) \
- r2 = MAXMIN_OP (r2, a[i]); \
- if (r1 != r2) \
- __builtin_abort (); \
+#define TEST_REDUC_FMAXMIN(TYPE, NAME, MAXMIN_OP) \
+ { \
+ INIT_VECTOR (TYPE); \
+ TYPE r1 = reduc_##NAME##_##TYPE (a, NUM_ELEMS (TYPE)); \
+ volatile TYPE r2 = -0.0; \
+ for (int i = 0; i < NUM_ELEMS (TYPE); ++i) \
+ r2 = MAXMIN_OP (r2, a[i]); \
+ if (r1 != r2) \
+ __builtin_abort (); \
}
__attribute__ ((optimize ("1")))