Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / pr48172.c
1 extern void *memset(void *s, int c, __SIZE_TYPE__ n);
2 extern void abort (void);
3
4 #define ASIZE 1028
5 #define HALF (ASIZE/2)
6
7 int main() {
8   unsigned int array[ASIZE];
9   int i;
10
11   memset(array, 0, sizeof(array));
12
13   /* initialize first half of the array */
14   for (i = 0; i < HALF; i++)
15     array[i] = i;
16
17   /* fill second half of array in by summing earlier elements of the array
18      gcc 4.5.1 and 4.5.2 incorrectly vectorize this loop!  aray[1025] is left
19      at 0 for ASIZE=1028 */
20   for (i = 0; i < HALF-1; i++)
21     array[HALF+i] = array[2*i] + array[2*i + 1];
22
23   /* see if we have any failures */
24   for (i = 0; i < HALF - 1; i++)
25     if (array[HALF+i] != array[2*i] + array[2*i + 1])
26       abort ();
27
28   return 0;
29 }
30
31 /* { dg-final { cleanup-tree-dump "vect" } } */