| 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) |
| 8 |
{ |
| 9 |
unsigned short res = 0; |
| 10 |
for (int i = 0; i < n; ++i) |
| 11 |
res += x[i]; |
| 12 |
return res; |
| 13 |
} |
| 14 |
|
| 15 |
unsigned short __attribute__((noipa)) |
| 16 |
min_loop (unsigned short *x, int n) |
| 17 |
{ |
| 18 |
unsigned short res = ~0; |
| 19 |
for (int i = 0; i < n; ++i) |
| 20 |
res = res < x[i] ? res : x[i]; |
| 21 |
return res; |
| 22 |
} |
| 23 |
|
| 24 |
unsigned short __attribute__((noipa)) |
| 25 |
max_loop (unsigned short *x, int n) |
| 26 |
{ |
| 27 |
unsigned short res = 0; |
| 28 |
for (int i = 0; i < n; ++i) |
| 29 |
res = res > x[i] ? res : x[i]; |
| 30 |
return res; |
| 31 |
} |
| 32 |
|
| 33 |
unsigned short __attribute__((noipa)) |
| 34 |
and_loop (unsigned short *x, int n) |
| 35 |
{ |
| 36 |
unsigned short res = ~0; |
| 37 |
for (int i = 0; i < n; ++i) |
| 38 |
res &= x[i]; |
| 39 |
return res; |
| 40 |
} |
| 41 |
|
| 42 |
unsigned short __attribute__((noipa)) |
| 43 |
or_loop (unsigned short *x, int n) |
| 44 |
{ |
| 45 |
unsigned short res = 0; |
| 46 |
for (int i = 0; i < n; ++i) |
| 47 |
res |= x[i]; |
| 48 |
return res; |
| 49 |
} |
| 50 |
|
| 51 |
unsigned short __attribute__((noipa)) |
| 52 |
eor_loop (unsigned short *x, int n) |
| 53 |
{ |
| 54 |
unsigned short res = 0; |
| 55 |
for (int i = 0; i < n; ++i) |
| 56 |
res ^= x[i]; |
| 57 |
return res; |
| 58 |
} |
| 59 |
|
| 60 |
/* { dg-final { scan-assembler-times {vredsum\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 61 |
/* { dg-final { scan-assembler-times {vredmaxu\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 62 |
/* { dg-final { scan-assembler-times {vredminu\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 63 |
/* { dg-final { scan-assembler-times {vredand\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 64 |
/* { dg-final { scan-assembler-times {vredor\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |
| 65 |
/* { dg-final { scan-assembler-times {vredxor\.vs\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+} 1 } } */ |