]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/vect/vect-106.c
Fix profile update after prologue peeling in vectorizer
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / vect / vect-106.c
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-additional-options "-fdump-tree-optimized-details-blocks" } */
3
4 #include <stdlib.h>
5 #include <stdarg.h>
6 #include "tree-vect.h"
7
8 #define N 9
9
10 static int a[N] = {1,2,3,4,5,6,7,8,9};
11 static int b[N] = {2,3,4,5,6,7,8,9,0};
12
13 __attribute__ ((noinline))
14 int main1 () {
15 int i;
16 int *p, *q, *p1, *q1;
17 p = (unsigned int *) malloc (sizeof (unsigned int) * N);
18 q = (unsigned int *) malloc (sizeof (unsigned int) * N);
19
20 p1 = p; q1 = q;
21
22 /* Vectorizable, before pointer plus we would get a redundant cast
23 (caused by pointer arithmetics), alias analysis fails to distinguish
24 between the pointers. */
25 for (i = 0; i < N; i++)
26 {
27 *(q + i) = a[i];
28 *(p + i) = b[i];
29 }
30
31 /* check results: */
32 for (i = 0; i < N; i++)
33 {
34 if (*q != a[i] || *p != b[i])
35 abort();
36 q++;
37 p++;
38 }
39
40 q = q1;
41 p = p1;
42 /* Vectorizable. */
43 for (i = 0; i < N; i++)
44 {
45 *q = b[i];
46 *p = a[i];
47 q++;
48 p++;
49 }
50
51 q = q1;
52 p = p1;
53 /* check results: */
54 for (i = 0; i < N; i++)
55 {
56 if (*q != b[i] || *p != a[i])
57 abort();
58 q++;
59 p++;
60 }
61
62 return 0;
63 }
64
65 int main (void)
66 {
67 check_vect ();
68
69 return main1 ();
70 }
71
72 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
73
74 /* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */