OSDN Git Service

PR tree-optimization/29145
[pf3gnuchains/gcc-fork.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,6,8},{8,9,9}};
18
19 int main1 (int x) {
20   int i,j;
21   struct extraction *p;
22   p = (struct extraction *) malloc (sizeof (struct extraction));
23
24   for (i = 0; i < N; i++)
25    {
26     for (j = 0; j < N; j++)
27      {
28        p->a[i][j] = a[i][j];
29        p->b[i][j] = b[i][j];
30        if (x == 135)
31          abort (); /* to avoid vectorization  */
32      }
33    }
34
35   /* Not vectorizable: distance = 1.  */
36   for (i = 1; i < N; i++)
37   {
38     for (j = 0; j < N; j++)
39     {
40        *((int *)p + x + i + j) = *((int *)p + x + i + j + 1);
41     }
42   }
43
44   /* check results: */
45   for (i = 0; i < N; i++)
46    {
47     for (j = 0; j < N; j++)
48      {
49        if (p->a[i][j] != c[i][j])
50          abort();
51      }
52   }
53   return 0;
54 }
55
56 int main (void)
57
58   check_vect ();
59
60   return main1 (N);
61 }
62
63 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
64 /* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
65 /* { dg-final { cleanup-tree-dump "vect" } } */
66