Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-100.c

raw
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 struct extraction
11 {
12 int a[N];
13 int b[N];
14 };
15
16 static int a[N] = {1,2,3,4,5,6,7,8,9};
17 static int b[N] = {2,3,4,5,6,7,8,9,0};
18
19 __attribute__ ((noinline))
20 int main1 () {
21 int i;
22 struct extraction *p;
23
24 p = (struct extraction *) malloc (sizeof (struct extraction));
25
26 /* Vectorizable: alias analysis determines that p can't point to a and/or b. */
27 for (i = 0; i < N; i++)
28 {
29 p->a[i] = a[i];
30 p->b[i] = b[i];
31 }
32
33 /* check results: */
34 #pragma GCC novector
35 for (i = 0; i < N; i++)
36 {
37 if (p->a[i] != a[i] || p->b[i] != b[i])
38 abort();
39 }
40
41 return 0;
42 }
43
44 __attribute__ ((noinline))
45 int main2 () {
46 int i;
47 int c[N] = {1,2,3,4,5,6,7,8,9};
48 int d[N] = {2,3,4,5,6,7,8,9,0};
49 struct extraction *p;
50 p = (struct extraction *) malloc (sizeof (struct extraction));
51
52 /* Vectorizable: c and d are local arrays. */
53 for (i = 0; i < N; i++)
54 {
55 p->a[i] = c[i];
56 p->b[i] = d[i];
57 }
58
59 /* check results: */
60 #pragma GCC novector
61 for (i = 0; i < N; i++)
62 {
63 if (p->a[i] != c[i] || p->b[i] != d[i])
64 abort();
65 }
66
67 return 0;
68 }
69
70 int main (void)
71 {
72 check_vect ();
73
74 main1 ();
75 main2 ();
76
77 return 0;
78 }
79
80 /* Requires versioning. */
81 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 0 "vect" } } */
82
83 /* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */