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 /* Since the fix for PR97307 which sinks the load of a[i], preventing
55 if-conversion to happen, targets that cannot do masked loads only
56 vectorize the inline copy. */
57 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target vect_masked_load } } } */
58 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target { ! vect_masked_load } } } } */
59 /* { dg-final { scan-tree-dump-times "optimizing condition reduction with FOLD_EXTRACT_LAST" 2 "vect" { target vect_fold_extract_last } } } */
60 /* { dg-final { scan-tree-dump-not "condition expression based on integer induction." "vect" } } */