Debian Codegraph @

gcc/testsuite/g++.target/riscv/rvv/xtheadvector/pr116593.C

raw
1 /* Test that we do not have ice when compile */
2 /* { dg-do compile } */
3 /* { dg-options "-march=rv32gc_zfh_xtheadvector -mabi=ilp32d -O2" { target { rv32 } } } */
4 /* { dg-options "-march=rv64gc_zfh_xtheadvector -mabi=lp64d -O2" { target { rv64 } } } */
5
6 #include <math.h>
7 #include <riscv_vector.h>
8 #include <vector>
9
10 static
11 vfloat32m8_t atan2_ps (vfloat32m8_t a, vfloat32m8_t b, size_t vl)
12 {
13 std::vector<float> tmpx (vl);
14 std::vector<float> tmpy (vl);
15 __riscv_vse32_v_f32m8 (tmpx.data (), a, vl);
16 __riscv_vse32_v_f32m8 (tmpy.data (), b, vl);
17 for (size_t i = 0; i < vl; i++)
18 {
19 tmpx[i] = atan2 (tmpx[i], tmpy[i]);
20 }
21 return __riscv_vle32_v_f32m8 (tmpx.data (), vl);
22 }
23
24 void
25 atan2 (const float *x, const float *y, float *out, int size, int ch)
26 {
27 for (int i = 0; i < ch; i++)
28 {
29 const float *xx = x + size * i;
30 const float *yy = y + size * i;
31 float *zz = out + size * i;
32
33 int n = size;
34 while (n > 0)
35 {
36 size_t vl = __riscv_vsetvl_e32m8 (n);
37 vfloat32m8_t _xx = __riscv_vle32_v_f32m8 (xx, vl);
38 vfloat32m8_t _yy = __riscv_vle32_v_f32m8 (yy, vl);
39 vfloat32m8_t _zz = atan2_ps (_xx, _yy, vl);
40 __riscv_vse32_v_f32m8 (zz, _zz, vl);
41 n -= vl;
42 xx += vl;
43 yy += vl;
44 zz += vl;
45 }
46 }
47 }