Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/base/pr118103-run-1.c

raw
1 /* { dg-do run { target { riscv_zvfh } } } */
2 /* { dg-options "-O3 -fno-strict-aliasing" } */
3
4 #include "riscv_vector.h"
5 #define N 4
6 typedef _Float16 float16_t;
7 float16_t a[N]; float16_t b[N];
8
9 void initialize () {
10 uint16_t tmp_0[N] = {43883, 3213, 238, 275, };
11
12 for (int i = 0; i < N; ++i)
13 {
14 union { float16_t f16; uint16_t u16; } converter;
15 converter.u16 = tmp_0[i];
16 a[i] = converter.f16;
17 }
18
19 for (int i = 0; i < N; ++i)
20 b[i] = 0;
21 }
22
23 void compute ()
24 {
25 int avl = N;
26 float16_t* ptr_a = a; float16_t* ptr_b = b;
27
28 for (size_t vl; avl > 0; avl -= vl)
29 {
30 vl = __riscv_vsetvl_e16m1(avl);
31 vfloat16m1_t va = __riscv_vle16_v_f16m1(ptr_a, vl);
32 va = __riscv_vfnmadd_vv_f16m1_rm(va, va, va, __RISCV_FRM_RDN, vl);
33 va = __riscv_vfmsac_vv_f16m1(va, va, va, vl);
34 __riscv_vse16_v_f16m1(ptr_b, va, vl);
35 ptr_a += vl; ptr_b += vl;
36 }
37 }
38
39 int main ()
40 {
41 initialize();
42 compute();
43
44 short *tmp = (short *)b;
45
46 if (*tmp != -21862)
47 __builtin_abort ();
48
49 return 0;
50 }