Debian Codegraph @

gcc/testsuite/gcc.target/riscv/rvv/xtheadvector/pr116592.c

raw
1 /* { dg-do assemble } */
2 /* { dg-options "-march=rv32gc_zfh_xtheadvector -mabi=ilp32d -O2 -save-temps" { target { rv32 } } } */
3 /* { dg-options "-march=rv64gc_zfh_xtheadvector -mabi=lp64d -O2 -save-temps" { target { rv64 } } } */
4
5 #include <math.h>
6 #include "riscv_vector.h"
7
8 static vfloat32m8_t atan2_ps(vfloat32m8_t a, vfloat32m8_t b, size_t vl)
9 {
10 float tmpx[vl];
11 float tmpy[vl];
12 __riscv_vse32_v_f32m8(tmpx, a, vl);
13 __riscv_vse32_v_f32m8(tmpy, b, vl);
14 for (size_t i = 0; i < vl; i++)
15 {
16 tmpx[i] = atan2(tmpx[i], tmpy[i]);
17 }
18 return __riscv_vle32_v_f32m8(tmpx, vl);
19 }
20
21 void my_atan2(const float *x, const float *y, float *out, int size)
22 {
23 int n = size;
24 while (n > 0)
25 {
26 size_t vl = __riscv_vsetvl_e32m8(n);
27 vfloat32m8_t _x = __riscv_vle32_v_f32m8(x, vl);
28 vfloat32m8_t _y = __riscv_vle32_v_f32m8(y, vl);
29 vfloat32m8_t _out = atan2_ps(_x, _y, vl);
30 __riscv_vse32_v_f32m8(out, _out, vl);
31 n -= vl;
32 x += vl;
33 y += vl;
34 out += vl;
35 }
36 }
37
38 /* { dg-final { scan-assembler-not {th\.vsetvli\s+zero,0} } } */