OSDN Git Service

* gcc.dg/vect/vect-28.c: Fix test to not expect peeling on
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-106.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 9
8
9 static int a[N] = {1,2,3,4,5,6,7,8,9};
10 static int b[N] = {2,3,4,5,6,7,8,9,0};
11
12 int main1 () {
13   int i;
14   int *p, *q, *p1, *q1;
15   p = (unsigned int *) malloc (sizeof (unsigned int) * N);
16   q = (unsigned int *) malloc (sizeof (unsigned int) * N);
17
18   p1 = p; q1 = q;
19
20   /* Vectorizable, before pointer plus we would get a redundant cast
21      (caused by pointer arithmetics), alias analysis fails to distinguish
22      between the pointers.  */
23   for (i = 0; i < N; i++)
24     {
25       *(q + i) = a[i];
26       *(p + i) = b[i];
27     }
28
29   /* check results: */
30   for (i = 0; i < N; i++)
31     {
32        if (*q != a[i] || *p != b[i])
33          abort();
34        q++; 
35        p++;
36     }
37   
38   q = q1;
39   p = p1;
40   /* Vectorizable.  */ 
41   for (i = 0; i < N; i++)
42     {
43       *q = b[i];
44       *p = a[i];
45       q++;
46       p++;
47     }
48
49   q = q1;
50   p = p1;
51   /* check results: */
52   for (i = 0; i < N; i++)
53     {
54        if (*q != b[i] || *p != a[i])
55          abort();
56        q++;
57        p++;
58     }
59
60   return 0; 
61 }
62
63 int main (void)
64
65   check_vect ();
66
67   return main1 ();
68 }
69
70 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
71 /* { dg-final { cleanup-tree-dump "vect" } } */
72