1 /* { dg-require-effective-target vect_int } */
2 /* { dg-additional-options "--param max-completely-peel-times=1" } */
3
4 #include <stdarg.h>
5 #include "tree-vect.h"
6
7 #if VECTOR_BITS > 256
8 #define N (VECTOR_BITS / 16)
9 #else
10 #define N 16
11 #endif
12
13 unsigned short in[N];
14 unsigned short coef[N];
15 unsigned short a[N];
16
17 __attribute__ ((noinline)) unsigned int
18 foo (short scale){
19 int i;
20 unsigned short j;
21 unsigned int sum = 0;
22 unsigned short sum_j;
23
24 for (i = 0; i < N; i++) {
25 sum_j = 0;
26 for (j = 0; j < N; j++) {
27 sum_j += j;
28 }
29 a[i] = sum_j;
30 sum += ((unsigned int) in[i] * (unsigned int) coef[i]) >> scale;
31 }
32 return sum;
33 }
34
35 unsigned short
36 bar (void)
37 {
38 unsigned short j;
39 unsigned short sum_j;
40
41 sum_j = 0;
42 for (j = 0; j < N; j++) {
43 sum_j += j;
44 }
45
46 return sum_j;
47 }
48
49 int main (void)
50 {
51 int i;
52 unsigned short j, sum_j;
53 unsigned int sum = 0;
54 unsigned int res;
55
56 check_vect ();
57
58 for (i=0; i<N; i++){
59 in[i] = 2*i;
60 coef[i] = i;
61 }
62
63 res = foo (2);
64
65 /* check results: */
66 for (i=0; i<N; i++)
67 {
68 if (a[i] != bar ())
69 abort ();
70 sum += ((unsigned int) in[i] * (unsigned int) coef[i]) >> 2;
71 }
72 if (res != sum)
73 abort ();
74
75 return 0;
76 }
77
78 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { target vect_widen_mult_hi_to_si } } } */
79 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */