e44d3f3005add29478a79e58ed7d2370854ea8d8
[gcc.git] / gcc / testsuite / gcc.dg / vect / vect-reduc-2.c
1
2 /* { dg-require-effective-target vect_int } */
3
4 #include <stdarg.h>
5 #include "tree-vect.h"
6
7 #define N 16
8 #define DIFF 242
9
10 /* Test vectorization of reduction of signed-int. */
11
12 int main1 (int x, int max_result)
13 {
14 int i;
15 int b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
16 int c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
17 int diff = 2;
18 int max = x;
19 int min = 10;
20
21 for (i = 0; i < N; i++) {
22 diff += (b[i] - c[i]);
23 }
24
25 for (i = 0; i < N; i++) {
26 max = max < c[i] ? c[i] : max;
27 }
28
29 for (i = 0; i < N; i++) {
30 min = min > c[i] ? c[i] : min;
31 }
32
33 /* check results: */
34 if (diff != DIFF)
35 abort ();
36 if (max != max_result)
37 abort ();
38 if (min != 0)
39 abort ();
40
41 return 0;
42 }
43
44 int main (void)
45 {
46 check_vect ();
47
48 return main1 (100, 100);
49 return main1 (0, 15);
50 }
51
52 /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail {! vect_reduction} } } } */
53 /* { dg-final { cleanup-tree-dump "vect" } } */