Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-104.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 3
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},{4,5,6},{7,8,9}};
16 static int b[N][N] = {{17,24,7},{0,2,3},{4,31,82}};
17 static int c[N][N] = {{1,2,3},{4,5,5},{5,5,5}};
18 volatile int foo;
19
20 __attribute__ ((noinline))
21 int main1 (int x) {
22   int i,j;
23   struct extraction *p;
24   p = (struct extraction *) malloc (sizeof (struct extraction));
25
26   for (i = 0; i < N; i++)
27    {
28     for (j = 0; j < N; j++)
29      {
30        p->a[i][j] = a[i][j];
31        p->b[i][j] = b[i][j];
32        if (foo == 135)
33          abort (); /* to avoid vectorization  */
34      }
35    }
36
37   /* Not vectorizable: distance = 1.  */
38   for (i = 1; i < N; i++)
39   {
40     for (j = 0; j < N; j++)
41     {
42        *((int *)p + x + i + j + 1) = *((int *)p + x + i + j);
43     }
44   }
45
46   /* check results: */
47   for (i = 0; i < N; i++)
48    {
49     for (j = 0; j < N; j++)
50      {
51        if (p->a[i][j] != c[i][j])
52          abort();
53      }
54   }
55   return 0;
56 }
57
58 int main (void)
59
60   check_vect ();
61
62   foo = 0;
63   return main1 (N);
64 }
65
66 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
67 /* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" { target { ! vect_multiple_sizes } } } } */
68 /* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 2 "vect" { target vect_multiple_sizes } } } */
69 /* { dg-final { cleanup-tree-dump "vect" } } */
70