Merged r158465 through r158660 into branch.
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / no-scevccp-outer-7.c
blob9606d300cd2d122e780f468422d5e3eb19aa5f1f
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 16
8 unsigned short in[N];
9 unsigned short coef[N];
10 unsigned short a[N];
12 __attribute__ ((noinline)) unsigned int
13 foo (short scale){
14 int i;
15 unsigned short j;
16 unsigned int sum = 0;
17 unsigned short sum_j;
19 for (i = 0; i < N; i++) {
20 sum_j = 0;
21 for (j = 0; j < N; j++) {
22 sum_j += j;
24 a[i] = sum_j;
25 sum += ((unsigned int) in[i] * (unsigned int) coef[i]) >> scale;
27 return sum;
30 unsigned short
31 bar (void)
33 unsigned short j;
34 unsigned short sum_j;
36 sum_j = 0;
37 for (j = 0; j < N; j++) {
38 sum_j += j;
41 return sum_j;
44 int main (void)
46 int i;
47 unsigned short j, sum_j;
48 unsigned int sum = 0;
49 unsigned int res;
51 check_vect ();
53 for (i=0; i<N; i++){
54 in[i] = 2*i;
55 coef[i] = i;
58 res = foo (2);
60 /* check results: */
61 for (i=0; i<N; i++)
63 if (a[i] != bar ())
64 abort ();
65 sum += ((unsigned int) in[i] * (unsigned int) coef[i]) >> 2;
67 if (res != sum)
68 abort ();
70 return 0;
73 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { target vect_widen_mult_hi_to_si } } } */
74 /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" } } */
75 /* { dg-final { cleanup-tree-dump "vect" } } */