| 1 |
/* { dg-require-effective-target vect_condition } */ |
| 2 |
|
| 3 |
#include "tree-vect.h" |
| 4 |
|
| 5 |
extern void abort (void) __attribute__ ((noreturn)); |
| 6 |
|
| 7 |
#if VECTOR_BITS > 256 |
| 8 |
#define N (VECTOR_BITS / 8) |
| 9 |
#else |
| 10 |
#define N 32 |
| 11 |
#endif |
| 12 |
|
| 13 |
/* Condition reduction where loop size is not known at compile time. Will fail |
| 14 |
to vectorize. Version inlined into main loop will vectorize. */ |
| 15 |
|
| 16 |
unsigned char |
| 17 |
condition_reduction (unsigned char *a, unsigned char min_v, int count) |
| 18 |
{ |
| 19 |
unsigned char last = 65; |
| 20 |
|
| 21 |
for (int i = 0; i < count; i++) |
| 22 |
if (a[i] < min_v) |
| 23 |
last = a[i]; |
| 24 |
|
| 25 |
return last; |
| 26 |
} |
| 27 |
|
| 28 |
int |
| 29 |
main (void) |
| 30 |
{ |
| 31 |
unsigned char a[N] = { |
| 32 |
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 33 |
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 34 |
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 35 |
31, 32 |
| 36 |
}; |
| 37 |
for (int i = 32; i < N; ++i) |
| 38 |
{ |
| 39 |
a[i] = 70 + (i & 3); |
| 40 |
asm volatile ("" ::: "memory"); |
| 41 |
} |
| 42 |
|
| 43 |
check_vect (); |
| 44 |
|
| 45 |
unsigned char ret = condition_reduction (a, 16, N); |
| 46 |
|
| 47 |
if (ret != 10) |
| 48 |
abort (); |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |
| 52 |
|
| 53 |
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target { ! vect_fold_extract_last } } } } */ |
| 54 |
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target vect_fold_extract_last } } } */ |
| 55 |
/* { dg-final { scan-tree-dump "loop size is greater than data size" "vect" { xfail vect_fold_extract_last } } } */ |
| 56 |
/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ |
| 57 |
/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ |