Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-105.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdlib.h>
4 #include <stdarg.h>
5 #include "tree-vect.h"
6
7 #define N 4
8
9 struct extraction
10 {
11   int a[N][N];
12   int b[N][N];
13 };
14
15 static int a[N][N] = {{1,2,3,11},{4,5,6,12},{7,8,9,13},{34,45,67,83}};
16 static int b[N][N] = {{17,28,15,23},{0,2,3,24},{4,31,82,25},{29,31,432,256}};
17 static int c[N][N] = {{1,2,3,11},{4,9,13,34},{45,67,83,13},{34,45,67,83}};
18
19 volatile int y;
20
21 __attribute__ ((noinline))
22 int main1 (int x) {
23   int i,j;
24   struct extraction *p;
25   p = (struct extraction *) malloc (sizeof (struct extraction));
26
27   for (i = 0; i < N; i++)
28    {
29     for (j = 0; j < N; j++)
30      {
31        p->a[i][j] = a[i][j];
32        p->b[i][j] = b[i][j];
33        /* Because Y is volatile, the compiler cannot move this check out
34           of the loop.  */
35        if (y)
36          abort (); /* to avoid vectorization  */
37      }
38    }
39
40   /* Vectorizable: distance > number of iterations.  */
41   for (i = 1; i < N; i++)
42   {
43     for (j = 0; j < N; j++)
44     {
45        *((int *)p + x + i + j) = *((int *)p + x + i + j + 5);
46     }
47   }
48
49   /* check results: */
50   for (i = 0; i < N; i++)
51    {
52     for (j = 0; j < N; j++)
53      {
54        if (p->a[i][j] != c[i][j])
55          abort();
56      }
57   }
58   return 0;
59 }
60
61 int main (void)
62
63   check_vect ();
64
65   return main1 (N);
66 }
67
68 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
69 /*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 2 "vect" { target vect_no_align } } } */
70 /* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 0 "vect" } } */
71 /* { dg-final { cleanup-tree-dump "vect" } } */
72