Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/vfsqrt-zvfh-run.c

raw
1 /* { dg-do run { target { riscv_zvfh && riscv_zfh } } } */
2 /* { dg-additional-options "-std=c99 -fno-vect-cost-model -mrvv-vector-bits=zvl -ffast-math" } */
3
4 #include "vfsqrt-template.h"
5
6 /* We cannot link this without the Zvfh extension so define
7 it here instead of in the template directly. */
8 TEST_TYPE(_Float16, f16)
9
10 #define SZ 255
11
12 #define EPS 1e-5
13
14 #define RUN(TYPE, SUFFIX) \
15 TYPE a##TYPE[SZ]; \
16 for (int i = 0; i < SZ; i++) \
17 { \
18 a##TYPE[i] = (TYPE) i; \
19 } \
20 vsqrt_##TYPE (a##TYPE, a##TYPE, SZ); \
21 for (int i = 0; i < SZ; i++) \
22 if (__builtin_fabs##SUFFIX (a##TYPE[i] \
23 - __builtin_sqrt##SUFFIX ((TYPE) i)) \
24 > EPS) \
25 __builtin_abort ();
26
27 #define RUN_ALL() \
28 RUN (_Float16, f16)
29
30 int main ()
31 {
32 RUN_ALL()
33 }