Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lfloor-run-0.c

raw
1 /* { dg-do run { target { riscv_v && rv64 } } } */
2 /* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */
3
4 #include "test-math.h"
5
6 #define ARRAY_SIZE 128
7
8 double in[ARRAY_SIZE];
9 long out[ARRAY_SIZE];
10 long ref[ARRAY_SIZE];
11
12 TEST_UNARY_CALL_CVT (double, long, __builtin_lfloor)
13 TEST_ASSERT (long)
14
15 TEST_INIT_CVT (double, 1.2, long, __builtin_lfloor (1.2), 1)
16 TEST_INIT_CVT (double, -1.2, long, __builtin_lfloor (-1.2), 2)
17 TEST_INIT_CVT (double, 0.5, long, __builtin_lfloor (0.5), 3)
18 TEST_INIT_CVT (double, -0.5, long, __builtin_lfloor (-0.5), 4)
19 TEST_INIT_CVT (double, 0.1, long, __builtin_lfloor (0.1), 5)
20 TEST_INIT_CVT (double, -0.1, long, __builtin_lfloor (-0.1), 6)
21 TEST_INIT_CVT (double, 3.0, long, __builtin_lfloor (3.0), 7)
22 TEST_INIT_CVT (double, -3.0, long, __builtin_lfloor (-3.0), 8)
23 TEST_INIT_CVT (double, 4503599627370495.5, long, __builtin_lfloor (4503599627370495.5), 9)
24 TEST_INIT_CVT (double, 4503599627370497.0, long, __builtin_lfloor (4503599627370497.0), 10)
25 TEST_INIT_CVT (double, -4503599627370495.5, long, __builtin_lfloor (-4503599627370495.5), 11)
26 TEST_INIT_CVT (double, -4503599627370496.0, long, __builtin_lfloor (-4503599627370496.0), 12)
27 TEST_INIT_CVT (double, 0.0, long, __builtin_lfloor (-0.0), 13)
28 TEST_INIT_CVT (double, -0.0, long, __builtin_lfloor (-0.0), 14)
29 TEST_INIT_CVT (double, 9223372036854774784.0, long, __builtin_lfloor (9223372036854774784.0), 15)
30 TEST_INIT_CVT (double, 9223372036854775808.0, long, 0x7fffffffffffffff, 16)
31 TEST_INIT_CVT (double, -9223372036854775808.0, long, __builtin_lfloor (-9223372036854775808.0), 17)
32 TEST_INIT_CVT (double, -9223372036854777856.0, long, 0x8000000000000000, 18)
33 TEST_INIT_CVT (double, __builtin_inf (), long, __builtin_lfloor (__builtin_inf ()), 19)
34 TEST_INIT_CVT (double, -__builtin_inf (), long, __builtin_lfloor (-__builtin_inf ()), 20)
35 TEST_INIT_CVT (double, __builtin_nan (""), long, 0x7fffffffffffffff, 21)
36
37 /*
38 Similar to lround, some reference are hard-code instead of leveraging
39 scalar __builtin_lfloor because the return value of a NaN or an infinity,
40 or the rounded value is too large to be stored in a long is UNSPECIFIED.
41 */
42
43 int
44 main ()
45 {
46 RUN_TEST_CVT (double, long, 1, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
47 RUN_TEST_CVT (double, long, 2, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
48 RUN_TEST_CVT (double, long, 3, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
49 RUN_TEST_CVT (double, long, 4, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
50 RUN_TEST_CVT (double, long, 5, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
51 RUN_TEST_CVT (double, long, 6, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
52 RUN_TEST_CVT (double, long, 7, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
53 RUN_TEST_CVT (double, long, 8, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
54 RUN_TEST_CVT (double, long, 9, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
55 RUN_TEST_CVT (double, long, 10, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
56 RUN_TEST_CVT (double, long, 11, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
57 RUN_TEST_CVT (double, long, 12, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
58 RUN_TEST_CVT (double, long, 13, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
59 RUN_TEST_CVT (double, long, 14, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
60 RUN_TEST_CVT (double, long, 15, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
61 RUN_TEST_CVT (double, long, 16, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
62 RUN_TEST_CVT (double, long, 17, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
63 RUN_TEST_CVT (double, long, 18, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
64 RUN_TEST_CVT (double, long, 19, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
65 RUN_TEST_CVT (double, long, 20, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
66 RUN_TEST_CVT (double, long, 21, __builtin_lfloor, in, out, ref, ARRAY_SIZE);
67
68 return 0;
69 }