| 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 32 |
| 8 |
|
| 9 |
/* Simple condition reduction where the result is a negative of the induction. |
| 10 |
Will fail to vectorize to a simple case. */ |
| 11 |
|
| 12 |
signed int |
| 13 |
condition_reduction (signed int *a, signed int min_v) |
| 14 |
{ |
| 15 |
signed int last = -1; |
| 16 |
|
| 17 |
for (signed int i = 0; i < N; i++) |
| 18 |
if (a[i] < min_v) |
| 19 |
last = -i; |
| 20 |
|
| 21 |
return last; |
| 22 |
} |
| 23 |
|
| 24 |
int |
| 25 |
main (void) |
| 26 |
{ |
| 27 |
signed int a[N] = { |
| 28 |
11, -12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 29 |
1, 2, -3, 4, 5, 6, 7, -8, 9, 10, |
| 30 |
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 31 |
31, 32 |
| 32 |
}; |
| 33 |
|
| 34 |
check_vect (); |
| 35 |
|
| 36 |
signed int ret = condition_reduction (a, 16); |
| 37 |
|
| 38 |
if (ret != -19) |
| 39 |
abort (); |
| 40 |
|
| 41 |
return 0; |
| 42 |
} |
| 43 |
|
| 44 |
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" } } */ |
| 45 |
/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target { vect_fold_extract_last && { ! vect_multiple_sizes } } } } } */ |
| 46 |
/* { dg-final { scan-tree-dump "optimizing condition reduction with FOLD_EXTRACT_LAST" "vect" { target { vect_fold_extract_last && vect_multiple_sizes } } } } */ |
| 47 |
/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ |