Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / costmodel / ppc / costmodel-vect-outer-fir.c
blob49a909805a32f2c7acbd690dd94da4dcc1babecc
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 /* Currently not vectorized because we get too many BBs in the inner-loop,
15 because the compiler doesn't realize that the inner-loop executes at
16 least once (cause k<4), and so there's no need to create a guard code
17 to skip the inner-loop in case it doesn't execute. */
18 __attribute__ ((noinline)) void foo (){
19 int i,j,k;
20 float diff;
22 for (i = 0; i < N; i++) {
23 out[i] = 0;
26 for (k = 0; k < 4; k++) {
27 for (i = 0; i < N; i++) {
28 diff = 0;
29 for (j = k; j < M; j+=4) {
30 diff += in[j+i]*coeff[j];
32 out[i] += diff;
37 /* Vectorized. Changing misalignment in the inner-loop. */
38 __attribute__ ((noinline)) void fir (){
39 int i,j,k;
40 float diff;
42 for (i = 0; i < N; i++) {
43 diff = 0;
44 for (j = 0; j < M; j++) {
45 diff += in[j+i]*coeff[j];
47 fir_out[i] = diff;
52 int main (void)
54 check_vect ();
55 int i, j;
56 float diff;
58 for (i = 0; i < M; i++)
59 coeff[i] = i;
60 for (i = 0; i < N+M; i++)
61 in[i] = i;
63 foo ();
64 fir ();
66 for (i = 0; i < N; i++) {
67 if (out[i] != fir_out[i])
68 abort ();
71 return 0;
74 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 2 "vect" { xfail *-*-* } } } */
75 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail vect_no_align } } } */
76 /* { dg-final { cleanup-tree-dump "vect" } } */