OSDN Git Service

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