Debian Codegraph @

gcc/testsuite/g++.target/riscv/rvv/autovec/pr119547.C

raw
1 /* { dg-do run { target rv64 } } */
2 /* { dg-require-effective-target riscv_v_ok } */
3 /* { dg-options "-O3 -march=rv64gcv -mabi=lp64d --param=logical-op-non-short-circuit=0" } */
4
5 #include <riscv_vector.h>
6 using v_int32 = vint32m2_t;
7 using v_float64 = vfloat64m2_t;
8 struct Size
9 {
10 int width;
11 int height;
12 };
13 template <class> struct VTraits
14 {
15 static int vlanes () { return __riscv_vsetvlmax_e32m2 (); }
16 };
17 v_int32
18 v_load_expand_q (const signed char *ptr)
19 {
20 return __riscv_vwcvt_x (
21 __riscv_vwcvt_x (__riscv_vle8_v_i8mf2 (ptr, VTraits<v_int32>::vlanes ()),
22 VTraits<v_int32>::vlanes ()),
23 VTraits<v_int32>::vlanes ());
24 }
25 v_float64
26 v_cvt_f64_high (v_int32 a)
27 {
28 return __riscv_vget_f64m2 (__riscv_vfwcvt_f (a, VTraits<v_int32>::vlanes ()),
29 1);
30 }
31 void
32 v_store (double *ptr, v_float64 a)
33 {
34 __riscv_vse64 (ptr, a, __riscv_vsetvlmax_e64m2 ());
35 }
36 void
37 v_store_pair_as (double *ptr, v_float64 b)
38 {
39 v_store (ptr, b);
40 }
41 void
42 vx_load_pair_as (const signed char *ptr, v_float64, v_float64 &b)
43 {
44 v_int32 v0;
45 b = v_cvt_f64_high (v0);
46 };
47 void
48 cvt_64f (const signed char *src, double *dst, Size size)
49 {
50 int VECSZ = __riscv_vsetvlmax_e64m2 ();
51 for (int i; i < size.height; i++)
52 {
53 int j;
54 for (;; j += VECSZ)
55 {
56 if (j > -VECSZ)
57 if (j == 0 || dst)
58 break;
59 v_float64 v0, v1;
60 vx_load_pair_as (src, v0, v1);
61 v_store_pair_as (dst, v1);
62 }
63 for (; j < size.width; j++)
64 dst[j] = (src[j]);
65 }
66 }
67 void
68 cvtScale8s64f (unsigned char *src_, unsigned char *dst_,
69 size_t, Size size, void *)
70 {
71 signed char src;
72 double dst = *dst_;
73 cvt_64f (&src, &dst, size);
74 }
75 int main ()
76 {
77 unsigned char src[1];
78 unsigned char dst[1024];
79 double scale[1];
80 Size size{4, 1};
81 cvtScale8s64f (src, dst, 32, size, scale);
82 }