| 1 |
/* { dg-require-effective-target vect_condition } */ |
| 2 |
|
| 3 |
#include "tree-vect.h" |
| 4 |
|
| 5 |
extern void abort (void) __attribute__ ((noreturn)); |
| 6 |
|
| 7 |
#define N 37 |
| 8 |
|
| 9 |
/* Non-simple condition reduction with additional variable and unsigned |
| 10 |
types. */ |
| 11 |
|
| 12 |
unsigned int |
| 13 |
condition_reduction (unsigned int *a, unsigned int min_v, unsigned int *b) |
| 14 |
{ |
| 15 |
unsigned int last = N + 65; |
| 16 |
unsigned int aval; |
| 17 |
|
| 18 |
for (unsigned int i = 0; i < N; i++) |
| 19 |
{ |
| 20 |
aval = a[i]; |
| 21 |
if (b[i] < min_v) |
| 22 |
last = aval; |
| 23 |
} |
| 24 |
return last; |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
int |
| 29 |
main (void) |
| 30 |
{ |
| 31 |
unsigned int a[N] = { |
| 32 |
31, 32, 33, 34, 35, 36, 37, |
| 33 |
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 34 |
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 35 |
11, 12, 13, 14, 15, 16, 17, 18, 19, 20 |
| 36 |
}; |
| 37 |
unsigned int b[N] = { |
| 38 |
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 39 |
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 40 |
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 41 |
31, 32, 33, 34, 35, 36, 37 |
| 42 |
}; |
| 43 |
|
| 44 |
check_vect (); |
| 45 |
|
| 46 |
unsigned int ret = condition_reduction (a, 16, b); |
| 47 |
|
| 48 |
if (ret != 13) |
| 49 |
abort (); |
| 50 |
|
| 51 |
return 0; |
| 52 |
} |
| 53 |
|
| 54 |
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ |
| 55 |
/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */ |
| 56 |
/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ |