Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-106.c
blobd578d814326a5b8f368e1b720595670be7929940
1 /* { dg-require-effective-target vect_int } */
3 #include <stdlib.h>
4 #include <stdarg.h>
5 #include "tree-vect.h"
7 #define N 9
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};
12 __attribute__ ((noinline))
13 int main1 () {
14 int i;
15 int *p, *q, *p1, *q1;
16 p = (unsigned int *) malloc (sizeof (unsigned int) * N);
17 q = (unsigned int *) malloc (sizeof (unsigned int) * N);
19 p1 = p; q1 = q;
21 /* Vectorizable, before pointer plus we would get a redundant cast
22 (caused by pointer arithmetics), alias analysis fails to distinguish
23 between the pointers. */
24 for (i = 0; i < N; i++)
26 *(q + i) = a[i];
27 *(p + i) = b[i];
30 /* check results: */
31 for (i = 0; i < N; i++)
33 if (*q != a[i] || *p != b[i])
34 abort();
35 q++;
36 p++;
39 q = q1;
40 p = p1;
41 /* Vectorizable. */
42 for (i = 0; i < N; i++)
44 *q = b[i];
45 *p = a[i];
46 q++;
47 p++;
50 q = q1;
51 p = p1;
52 /* check results: */
53 for (i = 0; i < N; i++)
55 if (*q != b[i] || *p != a[i])
56 abort();
57 q++;
58 p++;
61 return 0;
64 int main (void)
66 check_vect ();
68 return main1 ();
71 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
72 /* { dg-final { cleanup-tree-dump "vect" } } */