| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-additional-options "-march=rv32gcv -mabi=ilp32d -mrvv-vector-bits=scalable -ffast-math -fno-vect-cost-model" } */ |
| 3 |
|
| 4 |
#include <stdint-gcc.h> |
| 5 |
|
| 6 |
unsigned short __attribute__((noipa)) |
| 7 |
add_loop (unsigned short *x, int n, unsigned short res) |
| 8 |
{ |
| 9 |
for (int i = 0; i < n; ++i) |
| 10 |
res += x[i]; |
| 11 |
return res; |
| 12 |
} |
| 13 |
|
| 14 |
unsigned short __attribute__((noipa)) |
| 15 |
min_loop (unsigned short *x, int n, unsigned short res) |
| 16 |
{ |
| 17 |
for (int i = 0; i < n; ++i) |
| 18 |
res = res < x[i] ? res : x[i]; |
| 19 |
return res; |
| 20 |
} |
| 21 |
|
| 22 |
unsigned short __attribute__((noipa)) |
| 23 |
max_loop (unsigned short *x, int n, unsigned short res) |
| 24 |
{ |
| 25 |
for (int i = 0; i < n; ++i) |
| 26 |
res = res > x[i] ? res : x[i]; |
| 27 |
return res; |
| 28 |
} |
| 29 |
|
| 30 |
unsigned short __attribute__((noipa)) |
| 31 |
and_loop (unsigned short *x, int n, unsigned short res) |
| 32 |
{ |
| 33 |
for (int i = 0; i < n; ++i) |
| 34 |
res &= x[i]; |
| 35 |
return res; |
| 36 |
} |
| 37 |
|
| 38 |
unsigned short __attribute__((noipa)) |
| 39 |
or_loop (unsigned short *x, int n, unsigned short res) |
| 40 |
{ |
| 41 |
for (int i = 0; i < n; ++i) |
| 42 |
res |= x[i]; |
| 43 |
return res; |
| 44 |
} |
| 45 |
|
| 46 |
unsigned short __attribute__((noipa)) |
| 47 |
eor_loop (unsigned short *x, int n, unsigned short res) |
| 48 |
{ |
| 49 |
for (int i = 0; i < n; ++i) |
| 50 |
res ^= x[i]; |
| 51 |
return res; |
| 52 |
} |
| 53 |
|
| 54 |
/* { dg-final { scan-assembler-times {vredsum\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 55 |
/* { dg-final { scan-assembler-times {vredmaxu\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 56 |
/* { dg-final { scan-assembler-times {vredminu\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 57 |
/* { dg-final { scan-assembler-times {vredand\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 58 |
/* { dg-final { scan-assembler-times {vredor\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 59 |
/* { dg-final { scan-assembler-times {vredxor\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |