| 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 255 |
| 8 |
|
| 9 |
/* Condition reduction with maximum possible loop size. Will fail to |
| 10 |
vectorize because the vectorisation requires a slot for default values. */ |
| 11 |
|
| 12 |
signed char __attribute__((noinline,noclone)) |
| 13 |
condition_reduction (signed char *a, signed char min_v) |
| 14 |
{ |
| 15 |
signed char last = -72; |
| 16 |
|
| 17 |
for (int i = 0; i < N; i++) |
| 18 |
if (a[i] < min_v) |
| 19 |
last = a[i]; |
| 20 |
|
| 21 |
return last; |
| 22 |
} |
| 23 |
|
| 24 |
int |
| 25 |
main () |
| 26 |
{ |
| 27 |
signed char 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 |
__builtin_memset (a+32, 43, N-32); |
| 34 |
|
| 35 |
check_vect (); |
| 36 |
|
| 37 |
signed char ret = condition_reduction (a, 16); |
| 38 |
if (ret != 10) |
| 39 |
abort (); |
| 40 |
|
| 41 |
ret = condition_reduction (a, 1); |
| 42 |
if (ret != -72) |
| 43 |
abort (); |
| 44 |
|
| 45 |
return 0; |
| 46 |
} |
| 47 |
|
| 48 |
/* { dg-final { scan-tree-dump-not "LOOP VECTORIZED" "vect" { target { ! vect_fold_extract_last } } } } */ |
| 49 |
/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target vect_fold_extract_last } } } */ |
| 50 |
/* { dg-final { scan-tree-dump "loop size is greater than data size" "vect" { target { ! vect_fold_extract_last } } } } */ |
| 51 |
/* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 1 "vect" { target vect_fold_extract_last } } } */ |
| 52 |
/* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */ |