| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-mrvv-vector-bits=scalable -march=rv32gcv -mabi=ilp32 -fno-tree-vectorize" } */ |
| 3 |
|
| 4 |
#include "riscv_vector.h" |
| 5 |
|
| 6 |
void f (void * restrict in, void * restrict out, int n, int cond) |
| 7 |
{ |
| 8 |
if (cond == 0) { |
| 9 |
vint8mf8_t v = *(vint8mf8_t*)(in + 100); |
| 10 |
*(vint8mf8_t*)(out + 100) = v; |
| 11 |
for (int i = 0; i < n; i++) |
| 12 |
{ |
| 13 |
vint16mf4_t v2 = __riscv_vmv_v_x_i16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); |
| 14 |
*(vint16mf4_t*)(out + i + 100) = v2; |
| 15 |
} |
| 16 |
} else if (cond == 1) { |
| 17 |
vint8mf8_t v = *(vint8mf8_t*)(in + 200); |
| 18 |
*(vint8mf8_t*)(out + 200) = v; |
| 19 |
for (int i = 0; i < n; i++) |
| 20 |
{ |
| 21 |
vint32mf2_t v2 = __riscv_vmv_v_x_i32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); |
| 22 |
*(vint32mf2_t*)(out + i + 200) = v2; |
| 23 |
} |
| 24 |
} else if (cond == 2) { |
| 25 |
vint8mf8_t v = *(vint8mf8_t*)(in + 300); |
| 26 |
*(vint8mf8_t*)(out + 300) = v; |
| 27 |
for (int i = 0; i < n; i++) |
| 28 |
{ |
| 29 |
vint8mf8_t v2 = __riscv_vmv_v_x_i8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); |
| 30 |
*(vint8mf8_t*)(out + i + 300) = v2; |
| 31 |
} |
| 32 |
} else if (cond == 3) { |
| 33 |
vint8mf8_t v = *(vint8mf8_t*)(in + 400); |
| 34 |
*(vint8mf8_t*)(out + 400) = v; |
| 35 |
for (int i = 0; i < n; i++) |
| 36 |
{ |
| 37 |
vint64m1_t v2 = __riscv_vmv_v_x_i64m1 (0, __riscv_vsetvlmax_e64m1 ()); |
| 38 |
*(vint64m1_t*)(out + i + 400) = v2; |
| 39 |
} |
| 40 |
} else if (cond == 4) { |
| 41 |
vint8mf8_t v = *(vint8mf8_t*)(in + 500); |
| 42 |
*(vint8mf8_t*)(out + 500) = v; |
| 43 |
for (int i = 0; i < n; i++) |
| 44 |
{ |
| 45 |
vfloat32mf2_t v2 = __riscv_vfmv_v_f_f32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); |
| 46 |
*(vfloat32mf2_t*)(out + i + 500) = v2; |
| 47 |
} |
| 48 |
} else if (cond == 5) { |
| 49 |
vuint8mf8_t v = *(vuint8mf8_t*)(in + 600); |
| 50 |
*(vuint8mf8_t*)(out + 600) = v; |
| 51 |
for (int i = 0; i < n; i++) |
| 52 |
{ |
| 53 |
vuint16mf4_t v2 = __riscv_vmv_v_x_u16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); |
| 54 |
*(vuint16mf4_t*)(out + i + 600) = v2; |
| 55 |
} |
| 56 |
} else if (cond == 6) { |
| 57 |
vuint8mf8_t v = *(vuint8mf8_t*)(in + 700); |
| 58 |
*(vuint8mf8_t*)(out + 700) = v; |
| 59 |
for (int i = 0; i < n; i++) |
| 60 |
{ |
| 61 |
vuint32mf2_t v2 = __riscv_vmv_v_x_u32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); |
| 62 |
*(vuint32mf2_t*)(out + i + 700) = v2; |
| 63 |
} |
| 64 |
} else if (cond == 7) { |
| 65 |
vuint8mf8_t v = *(vuint8mf8_t*)(in + 800); |
| 66 |
*(vuint8mf8_t*)(out + 800) = v; |
| 67 |
for (int i = 0; i < n; i++) |
| 68 |
{ |
| 69 |
vuint8mf8_t v2 = __riscv_vmv_v_x_u8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); |
| 70 |
*(vuint8mf8_t*)(out + i + 800) = v2; |
| 71 |
} |
| 72 |
} else if (cond == 8) { |
| 73 |
vuint8mf8_t v = *(vuint8mf8_t*)(in + 900); |
| 74 |
*(vuint8mf8_t*)(out + 900) = v; |
| 75 |
for (int i = 0; i < n; i++) |
| 76 |
{ |
| 77 |
vuint64m1_t v2 = __riscv_vmv_v_x_u64m1 (0, __riscv_vsetvlmax_e64m1 ()); |
| 78 |
*(vuint64m1_t*)(out + i + 900) = v2; |
| 79 |
} |
| 80 |
} else { |
| 81 |
vuint8mf8_t v = *(vuint8mf8_t*)(in + 1000); |
| 82 |
*(vuint8mf8_t*)(out + 1000) = v; |
| 83 |
for (int i = 0; i < n; i++) |
| 84 |
{ |
| 85 |
vfloat32mf2_t v2 = *(vfloat32mf2_t*)(in + i + 9000); |
| 86 |
*(vfloat32mf2_t*)(out + i + 1000) = v2; |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 92 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e64,\s*m1,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 93 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 94 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e32,\s*mf2,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 95 |
/* { dg-final { scan-assembler-times {vsetvli} 10 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |