| 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 (int8_t * restrict in, int8_t * restrict out, int n) |
| 7 |
{ |
| 8 |
switch (n) |
| 9 |
{ |
| 10 |
case 0:{ |
| 11 |
vint8mf8_t v = *(vint8mf8_t*)(in + 500); |
| 12 |
*(vint8mf8_t*)(out + 500) = v; |
| 13 |
break; |
| 14 |
} |
| 15 |
case 1:{ |
| 16 |
vint8mf8_t v = *(vint8mf8_t*)(in + 500); |
| 17 |
*(vint8mf8_t*)(out + 500) = v; |
| 18 |
break; |
| 19 |
} |
| 20 |
default:{ |
| 21 |
break; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
for (int i = 0 ; i < n * n; i++) |
| 26 |
out[i] = out[i] + out[i]; |
| 27 |
|
| 28 |
for (int i = 0 ; i < n * n * n; i++) |
| 29 |
out[i] = out[i] * out[i]; |
| 30 |
|
| 31 |
for (int i = 0 ; i < n * n * n * n; i++) |
| 32 |
out[i] = out[i] * out[i]; |
| 33 |
|
| 34 |
for (int i = 0 ; i < n * n * n * n; i++) { |
| 35 |
vint8mf8_t v = *(vint8mf8_t*)(in + 900 + i); |
| 36 |
*(vint8mf8_t*)(out + 900 + i) = v; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
void f2 (int8_t * restrict in, int8_t * restrict out, int n) |
| 41 |
{ |
| 42 |
switch (n) |
| 43 |
{ |
| 44 |
case 0:{ |
| 45 |
vint8mf4_t v = *(vint8mf4_t*)(in + 500); |
| 46 |
*(vint8mf4_t*)(out + 500) = v; |
| 47 |
break; |
| 48 |
} |
| 49 |
case 1:{ |
| 50 |
vint8mf4_t v = *(vint8mf4_t*)(in + 500); |
| 51 |
*(vint8mf4_t*)(out + 500) = v; |
| 52 |
break; |
| 53 |
} |
| 54 |
default:{ |
| 55 |
break; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
for (int i = 0 ; i < n * n; i++) |
| 60 |
out[i] = out[i] + out[i]; |
| 61 |
|
| 62 |
for (int i = 0 ; i < n * n * n; i++) |
| 63 |
out[i] = out[i] * out[i]; |
| 64 |
|
| 65 |
for (int i = 0 ; i < n * n * n * n; i++) |
| 66 |
out[i] = out[i] * out[i]; |
| 67 |
|
| 68 |
for (int i = 0 ; i < n * n * n * n; i++) { |
| 69 |
vint8mf4_t v = *(vint8mf4_t*)(in + 900 + i); |
| 70 |
*(vint8mf4_t*)(out + 900 + i) = v; |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
void f3 (int8_t * restrict in, int8_t * restrict out, int n) |
| 75 |
{ |
| 76 |
switch (n) |
| 77 |
{ |
| 78 |
case 0:{ |
| 79 |
vint8mf2_t v = *(vint8mf2_t*)(in + 500); |
| 80 |
*(vint8mf2_t*)(out + 500) = v; |
| 81 |
break; |
| 82 |
} |
| 83 |
case 1:{ |
| 84 |
vint8mf2_t v = *(vint8mf2_t*)(in + 500); |
| 85 |
*(vint8mf2_t*)(out + 500) = v; |
| 86 |
break; |
| 87 |
} |
| 88 |
default:{ |
| 89 |
break; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
for (int i = 0 ; i < n * n; i++) |
| 94 |
out[i] = out[i] + out[i]; |
| 95 |
|
| 96 |
for (int i = 0 ; i < n * n * n; i++) |
| 97 |
out[i] = out[i] * out[i]; |
| 98 |
|
| 99 |
for (int i = 0 ; i < n * n * n * n; i++) |
| 100 |
out[i] = out[i] * out[i]; |
| 101 |
|
| 102 |
for (int i = 0 ; i < n * n * n * n; i++) { |
| 103 |
vint8mf2_t v = *(vint8mf2_t*)(in + 900 + i); |
| 104 |
*(vint8mf2_t*)(out + 900 + i) = v; |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
void f4 (int8_t * restrict in, int8_t * restrict out, int n) |
| 109 |
{ |
| 110 |
switch (n) |
| 111 |
{ |
| 112 |
case 0:{ |
| 113 |
vint16mf4_t v = *(vint16mf4_t*)(in + 500); |
| 114 |
*(vint16mf4_t*)(out + 500) = v; |
| 115 |
break; |
| 116 |
} |
| 117 |
case 1:{ |
| 118 |
vint16mf4_t v = *(vint16mf4_t*)(in + 500); |
| 119 |
*(vint16mf4_t*)(out + 500) = v; |
| 120 |
break; |
| 121 |
} |
| 122 |
default:{ |
| 123 |
break; |
| 124 |
} |
| 125 |
} |
| 126 |
|
| 127 |
for (int i = 0 ; i < n * n; i++) |
| 128 |
out[i] = out[i] + out[i]; |
| 129 |
|
| 130 |
for (int i = 0 ; i < n * n * n; i++) |
| 131 |
out[i] = out[i] * out[i]; |
| 132 |
|
| 133 |
for (int i = 0 ; i < n * n * n * n; i++) |
| 134 |
out[i] = out[i] * out[i]; |
| 135 |
|
| 136 |
for (int i = 0 ; i < n * n * n * n; i++) { |
| 137 |
vint16mf4_t v = *(vint16mf4_t*)(in + 900 + i); |
| 138 |
*(vint16mf4_t*)(out + 900 + i) = v; |
| 139 |
} |
| 140 |
} |
| 141 |
|
| 142 |
void f5 (int8_t * restrict in, int8_t * restrict out, int n) |
| 143 |
{ |
| 144 |
switch (n) |
| 145 |
{ |
| 146 |
case 0:{ |
| 147 |
vint16mf2_t v = *(vint16mf2_t*)(in + 500); |
| 148 |
*(vint16mf2_t*)(out + 500) = v; |
| 149 |
break; |
| 150 |
} |
| 151 |
case 1:{ |
| 152 |
vint16mf2_t v = *(vint16mf2_t*)(in + 500); |
| 153 |
*(vint16mf2_t*)(out + 500) = v; |
| 154 |
break; |
| 155 |
} |
| 156 |
default:{ |
| 157 |
break; |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
for (int i = 0 ; i < n * n; i++) |
| 162 |
out[i] = out[i] + out[i]; |
| 163 |
|
| 164 |
for (int i = 0 ; i < n * n * n; i++) |
| 165 |
out[i] = out[i] * out[i]; |
| 166 |
|
| 167 |
for (int i = 0 ; i < n * n * n * n; i++) |
| 168 |
out[i] = out[i] * out[i]; |
| 169 |
|
| 170 |
for (int i = 0 ; i < n * n * n * n; i++) { |
| 171 |
vint16mf2_t v = *(vint16mf2_t*)(in + 900 + i); |
| 172 |
*(vint16mf2_t*)(out + 900 + i) = v; |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
void f6 (int8_t * restrict in, int8_t * restrict out, int n) |
| 177 |
{ |
| 178 |
switch (n) |
| 179 |
{ |
| 180 |
case 0:{ |
| 181 |
vint32mf2_t v = *(vint32mf2_t*)(in + 500); |
| 182 |
*(vint32mf2_t*)(out + 500) = v; |
| 183 |
break; |
| 184 |
} |
| 185 |
case 1:{ |
| 186 |
vint32mf2_t v = *(vint32mf2_t*)(in + 500); |
| 187 |
*(vint32mf2_t*)(out + 500) = v; |
| 188 |
break; |
| 189 |
} |
| 190 |
default:{ |
| 191 |
break; |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
for (int i = 0 ; i < n * n; i++) |
| 196 |
out[i] = out[i] + out[i]; |
| 197 |
|
| 198 |
for (int i = 0 ; i < n * n * n; i++) |
| 199 |
out[i] = out[i] * out[i]; |
| 200 |
|
| 201 |
for (int i = 0 ; i < n * n * n * n; i++) |
| 202 |
out[i] = out[i] * out[i]; |
| 203 |
|
| 204 |
for (int i = 0 ; i < n * n * n * n; i++) { |
| 205 |
vint32mf2_t v = *(vint32mf2_t*)(in + 900 + i); |
| 206 |
*(vint32mf2_t*)(out + 900 + i) = v; |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
/* { 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 "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 211 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e8,\s*mf4,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 212 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e8,\s*mf2,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 213 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 214 |
/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf2,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |
| 215 |
/* { 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 "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ |