| 1 |
/* { dg-do run { target { riscv_v } } } */ |
| 2 |
/* { dg-additional-options "-mrvv-vector-bits=zvl -ffast-math -fno-vect-cost-model" } */ |
| 3 |
|
| 4 |
#define N 0x1100 |
| 5 |
|
| 6 |
#include "reduc-5.c" |
| 7 |
|
| 8 |
int |
| 9 |
main (void) |
| 10 |
{ |
| 11 |
unsigned int x[N]; |
| 12 |
for (int i = 0; i < N; ++i) |
| 13 |
x[i] = ((i + 1) * (i + 2)) & 0xfffff; |
| 14 |
|
| 15 |
unsigned int add_res[2] = { 42, 1111 }; |
| 16 |
add_loop (x, add_res); |
| 17 |
if (add_res[0] != 968538154 |
| 18 |
|| add_res[1] != 964340823) |
| 19 |
__builtin_abort (); |
| 20 |
|
| 21 |
unsigned int max_res1[2] = { 0, 0 }; |
| 22 |
max_loop (x, max_res1); |
| 23 |
if (max_res1[0] != 1048150 |
| 24 |
|| max_res1[1] != 1045506) |
| 25 |
__builtin_abort (); |
| 26 |
|
| 27 |
unsigned int max_res2[2] = { 1048151, 1045507 }; |
| 28 |
max_loop (x, max_res2); |
| 29 |
if (max_res2[0] != 1048151 |
| 30 |
|| max_res2[1] != 1045507) |
| 31 |
__builtin_abort (); |
| 32 |
|
| 33 |
unsigned int or_res[2] = { 0x1000000, 0x2000000 }; |
| 34 |
or_loop (x, or_res); |
| 35 |
if (or_res[0] != 0x10ffffe |
| 36 |
|| or_res[1] != 0x20ffffe) |
| 37 |
__builtin_abort (); |
| 38 |
|
| 39 |
unsigned int eor_res[2] = { 0x1000000, 0x2000000 }; |
| 40 |
eor_loop (x, eor_res); |
| 41 |
if (eor_res[0] != 0x1010000 |
| 42 |
|| eor_res[1] != 0x20b5000) |
| 43 |
__builtin_abort (); |
| 44 |
|
| 45 |
for (int i = 0; i < N; ++i) |
| 46 |
x[i] = ~x[i] & 0xfffff; |
| 47 |
|
| 48 |
unsigned int min_res1[2] = { 500, 4000 }; |
| 49 |
min_loop (x, min_res1); |
| 50 |
if (min_res1[0] != 425 |
| 51 |
|| min_res1[1] != 3069) |
| 52 |
__builtin_abort (); |
| 53 |
|
| 54 |
unsigned int min_res2[2] = { 424, 3068 }; |
| 55 |
min_loop (x, min_res2); |
| 56 |
if (min_res2[0] != 424 |
| 57 |
|| min_res2[1] != 3068) |
| 58 |
__builtin_abort (); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |