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