Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112598-1.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-march=rv32gcv_zvfh_zfh_zvl512b -mabi=ilp32d -O3 -mrvv-max-lmul=m8 -O3 -fno-vect-cost-model -ffast-math" } */
3
4 #include <stdint-gcc.h>
5 #define TEST_UNARY_CALL_CVT(TYPE_IN, TYPE_OUT, CALL) \
6 void test_##TYPE_IN##_##TYPE_OUT##_##CALL ( \
7 TYPE_OUT *out, TYPE_IN *in, unsigned count) \
8 { \
9 for (unsigned i = 0; i < count; i++) \
10 out[i] = CALL (in[i]); \
11 }
12 #define TEST_ASSERT(TYPE) \
13 void test_##TYPE##_assert (TYPE *out, TYPE *ref, unsigned size) \
14 { \
15 for (unsigned i = 0; i < size; i++) \
16 { \
17 if (out[i] != ref[i]) \
18 __builtin_abort (); \
19 } \
20 }
21 #define TEST_INIT_CVT(TYPE_IN, VAL_IN, TYPE_REF, VAL_REF, NUM) \
22 void test_##TYPE_IN##_##TYPE_REF##_init_##NUM ( \
23 TYPE_IN *in, TYPE_REF *ref, unsigned size) \
24 { \
25 for (unsigned i = 0; i < size; i++) \
26 { \
27 in[i] = VAL_IN; \
28 ref[i] = VAL_REF; \
29 } \
30 }
31 #define RUN_TEST_CVT(TYPE_IN, TYPE_OUT, NUM, CALL, IN, OUT, REF, SIZE) \
32 test_##TYPE_IN##_##TYPE_OUT##_init_##NUM (IN, REF, SIZE); \
33 test_##TYPE_IN##_##TYPE_OUT##_##CALL (OUT, IN, SIZE); \
34 test_##TYPE_OUT##_assert (OUT, REF, SIZE);
35
36 #define ARRAY_SIZE 128
37
38 float in[ARRAY_SIZE];
39 int64_t out[ARRAY_SIZE];
40 int64_t ref[ARRAY_SIZE];
41
42 TEST_UNARY_CALL_CVT (float, int64_t, __builtin_llceilf)
43
44 TEST_ASSERT (int64_t)
45
46
47 TEST_INIT_CVT (float, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 26)
48 TEST_INIT_CVT (float, __builtin_inf (), int64_t, __builtin_llceilf (__builtin_inf ()), 29)
49
50 int64_t
51 main ()
52 {
53 RUN_TEST_CVT (float, int64_t, 26, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
54 RUN_TEST_CVT (float, int64_t, 29, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
55 return 0;
56 }