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