Debian Codegraph @

gcc/testsuite/g++.target/riscv/rvv/base/pr123808.C

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target riscv_v_ok } */
3 /* { dg-add-options riscv_v } */
4
5 #include <riscv_vector.h>
6 #include <vector>
7 #define a 36
8
9 uint8_t e[a], x[a];
10 int64_t f[a], g[a], l[a];
11 float j[a], k[a], m[a];
12
13 int main() {
14 for (int i = 0; i < a; ++i) { e[i]=1; g[i] = 86; x[i] = 86; }
15 for (size_t n = 0, avl = a; avl;) {
16 size_t o = __riscv_vsetvl_e64m8(avl);
17 vuint8m1_t p = __riscv_vle8_v_u8m1(&e[n], o);
18 vbool8_t q = __riscv_vmseq_vx_u8m1_b8(p, 1, o);
19 vuint64m8_t r = __riscv_vsll_vx_u64m8(__riscv_vid_v_u64m8(o), 3, o);
20 vint64m8_t s = __riscv_vluxei64_v_i64m8_tum(
21 __riscv_vlm_v_b8(std::vector<uint8_t>(o + 7).data(), o),
22 __riscv_vmv_v_x_i64m8(0, __riscv_vsetvlmax_e16m2()), &f[n], r, o);
23 vuint32m4_t t = __riscv_vsll_vx_u32m4(__riscv_vid_v_u32m4(o), 3, o);
24 vint64m8_t u = __riscv_vluxei32(&g[n], t, o);
25 vbool8_t v = __riscv_vlm_v_b8(&x[n], o);
26 __riscv_vle32ff_v_f32m4_mu(q, __riscv_vfmv_v_f_f32m4(0, __riscv_vsetvlmax_e8m1()), &j[n], &o, o);
27 vfloat32m1_t w = __riscv_vfmv_v_f_f32m1(0, __riscv_vsetvlmax_e32m1());
28 vfloat32m1_t aa = __riscv_vle32_v_f32m1_tu(w, &k[n], o);
29 s = __riscv_vcompress_vm_i64m8_tu(s, u, v, o);
30 vfloat32mf2_t ab = __riscv_vlmul_trunc_v_f32m1_f32mf2(aa);
31 vuint64m8_t ac = __riscv_vsll_vx_u64m8(__riscv_vid_v_u64m8(o), 3, o);
32 __riscv_vsuxei64_v_i64m8(&l[n], ac, s, o);
33 __riscv_vse32_v_f32mf2(&m[n], ab, o);
34 avl -= o;
35 }
36
37 /* Results are inconsistent between different VLENs.
38 "n" never changes so we will always store into l[0...] with a length of
39 "o". What differs is "s".
40 At zvl128b and zvl256b we have more than one loop iteration and
41 "s" will be {86, 86, -1, -1} or {86, 86, 0, 0} depending on the
42 tail/mask policy.
43 At zvl512b there is only one iteration and s = {86, 86, 86, ...}.
44 I cross checked with clang and this seems correct.
45 Therefore only check l's fifth element.
46 The actual PR is about fault-only-first loads and the wrong code
47 caused element 5 to be incorrect as well. */
48 if (l[5] != 86)
49 __builtin_abort ();
50 }