| 1 |
/* { dg-do run { target { riscv_v } } } */ |
| 2 |
/* { dg-additional-options "-mrvv-vector-bits=scalable -ffast-math -fno-vect-cost-model" } */ |
| 3 |
|
| 4 |
#define N 0x1100 |
| 5 |
|
| 6 |
#include "reduc-7.c" |
| 7 |
|
| 8 |
|
| 9 |
int |
| 10 |
main (void) |
| 11 |
{ |
| 12 |
unsigned int x[N]; |
| 13 |
for (int i = 0; i < N; ++i) |
| 14 |
x[i] = ((i + 1) * (i + 2)) & 0xfffff; |
| 15 |
|
| 16 |
unsigned int add_res1[2] = { 11, 22 }; |
| 17 |
add_loop (x, 0, add_res1); |
| 18 |
if (add_res1[0] != 11 |
| 19 |
|| add_res1[1] != 22) |
| 20 |
__builtin_abort (); |
| 21 |
|
| 22 |
unsigned int add_res2[2] = { 10, 20 }; |
| 23 |
add_loop (x, 11, add_res2); |
| 24 |
if (add_res2[0] != 1902 |
| 25 |
|| add_res2[1] != 2176) |
| 26 |
__builtin_abort (); |
| 27 |
|
| 28 |
unsigned int add_res3[2] = { 15, 30 }; |
| 29 |
add_loop (x, 0x100, add_res3); |
| 30 |
if (add_res3[0] != 22435087 |
| 31 |
|| add_res3[1] != 22566686) |
| 32 |
__builtin_abort (); |
| 33 |
|
| 34 |
unsigned int add_res4[2] = { 100, 200 }; |
| 35 |
add_loop (x, 0x11f, add_res4); |
| 36 |
if (add_res4[0] != 31602244 |
| 37 |
|| add_res4[1] != 31767656) |
| 38 |
__builtin_abort (); |
| 39 |
|
| 40 |
unsigned int max_res1[2] = { 461, 500 }; |
| 41 |
max_loop (x, 11, max_res1); |
| 42 |
if (max_res1[0] != 462 |
| 43 |
|| max_res1[1] != 506) |
| 44 |
__builtin_abort (); |
| 45 |
|
| 46 |
unsigned int max_res2[2] = { 463, 507 }; |
| 47 |
max_loop (x, 11, max_res2); |
| 48 |
if (max_res2[0] != 463 |
| 49 |
|| max_res2[1] != 507) |
| 50 |
__builtin_abort (); |
| 51 |
|
| 52 |
unsigned int max_res3[2] = { 1000000, 1000000 }; |
| 53 |
max_loop (x, 0x200, max_res3); |
| 54 |
if (max_res3[0] != 1047552 |
| 55 |
|| max_res3[1] != 1045506) |
| 56 |
__builtin_abort (); |
| 57 |
|
| 58 |
unsigned int max_res4[2] = { 1047553, 1045507 }; |
| 59 |
max_loop (x, 0x200, max_res4); |
| 60 |
if (max_res4[0] != 1047553 |
| 61 |
|| max_res4[1] != 1045507) |
| 62 |
__builtin_abort (); |
| 63 |
|
| 64 |
unsigned int max_res5[2] = { 300000, 30000 }; |
| 65 |
max_loop (x, 0x11f, max_res5); |
| 66 |
if (max_res5[0] != 328902 |
| 67 |
|| max_res5[1] != 330050) |
| 68 |
__builtin_abort (); |
| 69 |
|
| 70 |
unsigned int max_res6[2] = { 328903, 330051 }; |
| 71 |
max_loop (x, 0x11f, max_res6); |
| 72 |
if (max_res6[0] != 328903 |
| 73 |
|| max_res6[1] != 330051) |
| 74 |
__builtin_abort (); |
| 75 |
|
| 76 |
unsigned int or_res1[2] = { 11, 22 }; |
| 77 |
or_loop (x, 0, or_res1); |
| 78 |
if (or_res1[0] != 11 |
| 79 |
|| or_res1[1] != 22) |
| 80 |
__builtin_abort (); |
| 81 |
|
| 82 |
unsigned int or_res2[2] = { 0x200000, 0xe00000 }; |
| 83 |
or_loop (x, 11, or_res2); |
| 84 |
if (or_res2[0] != 0x2001fe |
| 85 |
|| or_res2[1] != 0xe001fe) |
| 86 |
__builtin_abort (); |
| 87 |
|
| 88 |
unsigned int or_res3[2] = { 0x800000, 0x700000 }; |
| 89 |
or_loop (x, 0x40, or_res3); |
| 90 |
if (or_res3[0] != 0x803ffe |
| 91 |
|| or_res3[1] != 0x707ffe) |
| 92 |
__builtin_abort (); |
| 93 |
|
| 94 |
unsigned int or_res4[2] = { 0x100001, 0x300000 }; |
| 95 |
or_loop (x, 0x4f, or_res4); |
| 96 |
if (or_res4[0] != 0x107fff |
| 97 |
|| or_res4[1] != 0x307ffe) |
| 98 |
__builtin_abort (); |
| 99 |
|
| 100 |
unsigned int eor_res1[2] = { 11, 22 }; |
| 101 |
eor_loop (x, 0, eor_res1); |
| 102 |
if (eor_res1[0] != 11 |
| 103 |
|| eor_res1[1] != 22) |
| 104 |
__builtin_abort (); |
| 105 |
|
| 106 |
unsigned int eor_res2[2] = { 0x2000ff, 0xe000ff }; |
| 107 |
eor_loop (x, 11, eor_res2); |
| 108 |
if (eor_res2[0] != 0x2001cf |
| 109 |
|| eor_res2[1] != 0xe000b7) |
| 110 |
__builtin_abort (); |
| 111 |
|
| 112 |
unsigned int eor_res3[2] = { 0x805000, 0x70f000 }; |
| 113 |
eor_loop (x, 0x100, eor_res3); |
| 114 |
if (eor_res3[0] != 0x824200 |
| 115 |
|| eor_res3[1] != 0x77dc00) |
| 116 |
__builtin_abort (); |
| 117 |
|
| 118 |
unsigned int eor_res4[2] = { 0x101201, 0x300f00 }; |
| 119 |
eor_loop (x, 0x11f, eor_res4); |
| 120 |
if (eor_res4[0] != 0x178801 |
| 121 |
|| eor_res4[1] != 0x337240) |
| 122 |
__builtin_abort (); |
| 123 |
|
| 124 |
for (int i = 0; i < N; ++i) |
| 125 |
x[i] = ~x[i] & 0xfffff; |
| 126 |
|
| 127 |
unsigned int min_res1[2] = { 1048200, 1048100 }; |
| 128 |
min_loop (x, 11, min_res1); |
| 129 |
if (min_res1[0] != 1048113 |
| 130 |
|| min_res1[1] != 1048069) |
| 131 |
__builtin_abort (); |
| 132 |
|
| 133 |
unsigned int min_res2[2] = { 1048112, 1048068 }; |
| 134 |
min_loop (x, 11, min_res2); |
| 135 |
if (min_res2[0] != 1048112 |
| 136 |
|| min_res2[1] != 1048068) |
| 137 |
__builtin_abort (); |
| 138 |
|
| 139 |
unsigned int min_res3[2] = { 10000, 10000 }; |
| 140 |
min_loop (x, 0x200, min_res3); |
| 141 |
if (min_res3[0] != 1023 |
| 142 |
|| min_res3[1] != 3069) |
| 143 |
__builtin_abort (); |
| 144 |
|
| 145 |
unsigned int min_res4[2] = { 1022, 3068 }; |
| 146 |
min_loop (x, 0x200, min_res4); |
| 147 |
if (min_res4[0] != 1022 |
| 148 |
|| min_res4[1] != 3068) |
| 149 |
__builtin_abort (); |
| 150 |
|
| 151 |
unsigned int min_res5[2] = { 719680, 718530 }; |
| 152 |
min_loop (x, 0x11f, min_res5); |
| 153 |
if (min_res5[0] != 719673 |
| 154 |
|| min_res5[1] != 718525) |
| 155 |
__builtin_abort (); |
| 156 |
|
| 157 |
unsigned int min_res6[2] = { 719672, 718524 }; |
| 158 |
min_loop (x, 0x11f, min_res6); |
| 159 |
if (min_res6[0] != 719672 |
| 160 |
|| min_res6[1] != 718524) |
| 161 |
__builtin_abort (); |
| 162 |
|
| 163 |
unsigned int and_res1[2] = { 11, 22 }; |
| 164 |
and_loop (x, 0, and_res1); |
| 165 |
if (and_res1[0] != 11 |
| 166 |
|| and_res1[1] != 22) |
| 167 |
__builtin_abort (); |
| 168 |
|
| 169 |
unsigned int and_res2[2] = { 0xf5cff, 0xf78ff }; |
| 170 |
and_loop (x, 11, and_res2); |
| 171 |
if (and_res2[0] != 0xf5c01 |
| 172 |
|| and_res2[1] != 0xf7801) |
| 173 |
__builtin_abort (); |
| 174 |
|
| 175 |
unsigned int and_res3[2] = { 0x7efff, 0xecfff }; |
| 176 |
and_loop (x, 0x40, and_res3); |
| 177 |
if (and_res3[0] != 0x7c001 |
| 178 |
|| and_res3[1] != 0xe8001) |
| 179 |
__builtin_abort (); |
| 180 |
|
| 181 |
unsigned int and_res4[2] = { 0xffffff, 0xffffff }; |
| 182 |
and_loop (x, 0x4f, and_res4); |
| 183 |
if (and_res4[0] != 0xf8001 |
| 184 |
|| and_res4[1] != 0xf8001) |
| 185 |
__builtin_abort (); |
| 186 |
|
| 187 |
return 0; |
| 188 |
} |