Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-rint-run-1.c

raw
1 /* { dg-do run { target { riscv_v } } } */
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 float in[ARRAY_SIZE];
9 float out[ARRAY_SIZE];
10 float ref[ARRAY_SIZE];
11
12 static float
13 get_ref_rintf (float val)
14 {
15 set_rm (FRM_RTZ);
16
17 return __builtin_rintf (val);
18 }
19
20 TEST_UNARY_CALL (float, __builtin_rintf)
21 TEST_ASSERT (float)
22
23 TEST_INIT (float, 1.2, get_ref_rintf (1.2), 1)
24 TEST_INIT (float, -1.2, get_ref_rintf (-1.2), 2)
25 TEST_INIT (float, 3.0, get_ref_rintf (3.0), 3)
26 TEST_INIT (float, 8388607.5, get_ref_rintf (8388607.5), 4)
27 TEST_INIT (float, 8388609.0, get_ref_rintf (8388609.0), 5)
28 TEST_INIT (float, 0.0, get_ref_rintf (0.0), 6)
29 TEST_INIT (float, -0.0, get_ref_rintf (-0.0), 7)
30 TEST_INIT (float, -8388607.5, get_ref_rintf (-8388607.5), 8)
31 TEST_INIT (float, -8388608.0, get_ref_rintf (-8388608.0), 9)
32
33 int
34 main ()
35 {
36 set_rm (FRM_RTZ);
37
38 RUN_TEST (float, 1, __builtin_rintf, in, out, ref, ARRAY_SIZE);
39 RUN_TEST (float, 2, __builtin_rintf, in, out, ref, ARRAY_SIZE);
40 RUN_TEST (float, 3, __builtin_rintf, in, out, ref, ARRAY_SIZE);
41 RUN_TEST (float, 4, __builtin_rintf, in, out, ref, ARRAY_SIZE);
42 RUN_TEST (float, 5, __builtin_rintf, in, out, ref, ARRAY_SIZE);
43 RUN_TEST (float, 6, __builtin_rintf, in, out, ref, ARRAY_SIZE);
44 RUN_TEST (float, 7, __builtin_rintf, in, out, ref, ARRAY_SIZE);
45 RUN_TEST (float, 8, __builtin_rintf, in, out, ref, ARRAY_SIZE);
46 RUN_TEST (float, 9, __builtin_rintf, in, out, ref, ARRAY_SIZE);
47
48 return 0;
49 }