Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-nest-cycle-3.c
1 /* { dg-require-effective-target vect_float } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 16
7 #define DIFF 82
8
9 float c[N][N], b[N][N], a[N];
10
11 __attribute__ ((noinline)) int 
12 main1 ()
13 {
14   int i, j;
15   float diff;
16
17   /* In inner loop vectorization -funsafe-math-optimizations is needed to 
18      vectorize the summation. But in outer loop vectorization the order of
19      calculation doesn't change, therefore, there is no need in that flag.  */
20   for (i = 0; i < N; i++)
21     {
22       diff = 2;
23       for (j = 0; j < N; j++) 
24         diff += (b[j][i] - c[j][i]);
25
26       a[i] = diff;
27     }
28
29   /* Check results:  */
30   for (i = 0; i < N; i++)
31     if (a[i] != DIFF)
32       abort ();
33
34   return 0;
35 }
36
37 int main (void)
38
39   int i, j;
40
41   check_vect ();
42   
43   for (i = 0; i < N; i++)
44     for (j = 0; j < N; j++)
45       {
46         b[i][j] = i+j+5;
47         c[i][j] = i+j;
48       }
49          
50   main1 ();
51
52   return 0;
53 }
54
55 /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */
56 /* { dg-final { cleanup-tree-dump "vect" } } */