1 /* { dg-require-effective-target vect_float } */
2 
3 #include <stdarg.h>
4 #include "../../tree-vect.h"
5 
6 #define N 40
7 #define M 128
8 float in[N+M];
9 float coeff[M];
10 float out[N];
11 float fir_out[N];
12 
13 /* Vectorized. Fixed misaligment in the inner-loop.  */
foo()14 __attribute__ ((noinline)) void foo (){
15  int i,j,k;
16  float diff;
17 
18  for (i = 0; i < N; i++) {
19   out[i] = 0;
20  }
21 
22  for (k = 0; k < 4; k++) {
23   for (i = 0; i < N; i++) {
24     diff = 0;
25     for (j = k; j < M; j+=4) {
26       diff += in[j+i]*coeff[j];
27     }
28     out[i] += diff;
29   }
30  }
31 }
32 
33 /* Vectorized. Changing misalignment in the inner-loop.  */
fir()34 __attribute__ ((noinline)) void fir (){
35   int i,j,k;
36   float diff;
37 
38   for (i = 0; i < N; i++) {
39     diff = 0;
40     for (j = 0; j < M; j++) {
41       diff += in[j+i]*coeff[j];
42     }
43     fir_out[i] = diff;
44   }
45 }
46 
47 
main(void)48 int main (void)
49 {
50   check_vect ();
51   int i, j;
52   float diff;
53 
54   for (i = 0; i < M; i++)
55     coeff[i] = i;
56   for (i = 0; i < N+M; i++)
57     in[i] = i;
58 
59   foo ();
60   fir ();
61 
62   for (i = 0; i < N; i++) {
63     if (out[i] != fir_out[i])
64       abort ();
65   }
66 
67   return 0;
68 }
69 
70 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */
71