| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
|
| 3 |
#include <stdarg.h> |
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
#define N 256 |
| 7 |
|
| 8 |
unsigned char ub[N]; |
| 9 |
unsigned char uc[N]; |
| 10 |
unsigned char diff; |
| 11 |
|
| 12 |
__attribute__ ((noinline)) void |
| 13 |
main1 (unsigned char x, unsigned char max_result, unsigned char min_result) |
| 14 |
{ |
| 15 |
int i; |
| 16 |
unsigned char udiff = 2; |
| 17 |
unsigned char umax = x; |
| 18 |
unsigned char umin = x; |
| 19 |
|
| 20 |
diff = 2; |
| 21 |
for (i = 0; i < N; i++) { |
| 22 |
ub[i] = i; |
| 23 |
uc[i] = i; |
| 24 |
if (i%16 == 0) |
| 25 |
{ |
| 26 |
ub[i] = i+2; |
| 27 |
diff += 2; |
| 28 |
} |
| 29 |
if (uc[i] > max_result) |
| 30 |
max_result = uc[i]; |
| 31 |
if (uc[i] < min_result) |
| 32 |
min_result = uc[i]; |
| 33 |
|
| 34 |
asm volatile ("" ::: "memory"); |
| 35 |
} |
| 36 |
for (i = 0; i < N; i++) { |
| 37 |
udiff += (unsigned char) (ub[i] - uc[i]); |
| 38 |
} |
| 39 |
|
| 40 |
for (i = 0; i < N; i++) { |
| 41 |
umax = umax < uc[i] ? uc[i] : umax; |
| 42 |
} |
| 43 |
|
| 44 |
for (i = 0; i < N; i++) { |
| 45 |
umin = umin > uc[i] ? uc[i] : umin; |
| 46 |
} |
| 47 |
|
| 48 |
/* check results: */ |
| 49 |
if (udiff != diff) |
| 50 |
abort (); |
| 51 |
if (umax != max_result) |
| 52 |
abort (); |
| 53 |
if (umin != min_result) |
| 54 |
abort (); |
| 55 |
} |
| 56 |
|
| 57 |
int main (void) |
| 58 |
{ |
| 59 |
check_vect (); |
| 60 |
|
| 61 |
main1 (100, 100, 1); |
| 62 |
main1 (0, 15, 0); |
| 63 |
return 0; |
| 64 |
} |
| 65 |
|
| 66 |
/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_min_max } } } */ |