| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-march=rv32gcv -mabi=ilp32d -mrvv-vector-bits=scalable -ffast-math -fno-vect-cost-model -fdump-tree-optimized-details" } */ |
| 3 |
|
| 4 |
void __attribute__((noipa)) |
| 5 |
add_loop (unsigned int *x, int n, unsigned int *res) |
| 6 |
{ |
| 7 |
unsigned int res0 = res[0]; |
| 8 |
unsigned int res1 = res[1]; |
| 9 |
for (int i = 0; i < n; ++i) |
| 10 |
{ |
| 11 |
res0 += x[i * 2]; |
| 12 |
res1 += x[i * 2 + 1]; |
| 13 |
} |
| 14 |
res[0] = res0; |
| 15 |
res[1] = res1; |
| 16 |
} |
| 17 |
|
| 18 |
void __attribute__((noipa)) |
| 19 |
min_loop (unsigned int *x, int n, unsigned int *res) |
| 20 |
{ |
| 21 |
unsigned int res0 = res[0]; |
| 22 |
unsigned int res1 = res[1]; |
| 23 |
for (int i = 0; i < n; ++i) |
| 24 |
{ |
| 25 |
res0 = res0 < x[i * 2] ? res0 : x[i * 2]; |
| 26 |
res1 = res1 < x[i * 2 + 1] ? res1 : x[i * 2 + 1]; |
| 27 |
} |
| 28 |
res[0] = res0; |
| 29 |
res[1] = res1; |
| 30 |
} |
| 31 |
|
| 32 |
void __attribute__((noipa)) |
| 33 |
max_loop (unsigned int *x, int n, unsigned int *res) |
| 34 |
{ |
| 35 |
unsigned int res0 = res[0]; |
| 36 |
unsigned int res1 = res[1]; |
| 37 |
for (int i = 0; i < n; ++i) |
| 38 |
{ |
| 39 |
res0 = res0 > x[i * 2] ? res0 : x[i * 2]; |
| 40 |
res1 = res1 > x[i * 2 + 1] ? res1 : x[i * 2 + 1]; |
| 41 |
} |
| 42 |
res[0] = res0; |
| 43 |
res[1] = res1; |
| 44 |
} |
| 45 |
|
| 46 |
void __attribute__((noipa)) |
| 47 |
and_loop (unsigned int *x, int n, unsigned int *res) |
| 48 |
{ |
| 49 |
unsigned int res0 = res[0]; |
| 50 |
unsigned int res1 = res[1]; |
| 51 |
for (int i = 0; i < n; ++i) |
| 52 |
{ |
| 53 |
res0 &= x[i * 2]; |
| 54 |
res1 &= x[i * 2 + 1]; |
| 55 |
} |
| 56 |
res[0] = res0; |
| 57 |
res[1] = res1; |
| 58 |
} |
| 59 |
|
| 60 |
void __attribute__((noipa)) |
| 61 |
or_loop (unsigned int *x, int n, unsigned int *res) |
| 62 |
{ |
| 63 |
unsigned int res0 = res[0]; |
| 64 |
unsigned int res1 = res[1]; |
| 65 |
for (int i = 0; i < n; ++i) |
| 66 |
{ |
| 67 |
res0 |= x[i * 2]; |
| 68 |
res1 |= x[i * 2 + 1]; |
| 69 |
} |
| 70 |
res[0] = res0; |
| 71 |
res[1] = res1; |
| 72 |
} |
| 73 |
|
| 74 |
void __attribute__((noipa)) |
| 75 |
eor_loop (unsigned int *x, int n, unsigned int *res) |
| 76 |
{ |
| 77 |
unsigned int res0 = res[0]; |
| 78 |
unsigned int res1 = res[1]; |
| 79 |
for (int i = 0; i < n; ++i) |
| 80 |
{ |
| 81 |
res0 ^= x[i * 2]; |
| 82 |
res1 ^= x[i * 2 + 1]; |
| 83 |
} |
| 84 |
res[0] = res0; |
| 85 |
res[1] = res1; |
| 86 |
} |
| 87 |
|
| 88 |
/* { dg-final { scan-tree-dump-times "VEC_SHL_INSERT" 8 "optimized" } } */ |