Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / vect / vect-outer-fir.c
blobaf787b96a33691d15e3cc570925f6ede80f84a28
1 /* { dg-require-effective-target vect_float } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
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];
13 /* Should be vectorized. Fixed misaligment in the inner-loop. */
14 __attribute__ ((noinline))
15 void foo (){
16 int i,j,k;
17 float diff;
19 for (i = 0; i < N; i++) {
20 out[i] = 0;
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];
29 out[i] += diff;
35 /* Vectorized. Changing misalignment in the inner-loop. */
36 __attribute__ ((noinline))
37 void fir (){
38 int i,j,k;
39 float diff;
41 for (i = 0; i < N; i++) {
42 diff = 0;
43 for (j = 0; j < M; j++) {
44 diff += in[j+i]*coeff[j];
46 fir_out[i] = diff;
51 int main (void)
53 check_vect ();
54 int i, j;
55 float diff;
57 for (i = 0; i < M; i++)
58 coeff[i] = i;
59 for (i = 0; i < N+M; i++)
60 in[i] = i;
62 foo ();
63 fir ();
65 for (i = 0; i < N; i++) {
66 if (out[i] != fir_out[i])
67 abort ();
70 return 0;
73 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail vect_no_align } } } */
74 /* { dg-final { cleanup-tree-dump "vect" } } */