Debian Codegraph @

gcc/testsuite/gcc.dg/vect/no-vfa-vect-43.c

raw
1 /* { dg-require-effective-target vect_float } */
2 /* { dg-additional-options "--param vect-max-version-for-alias-checks=0" } */
3
4 #include <stdarg.h>
5 #include "tree-vect.h"
6
7 #define N 256
8
9 __attribute__ ((noinline))
10 void bar (float *pa, float *pb, float *pc)
11 {
12 int i;
13
14 /* check results: */
15 #pragma GCC novector
16 for (i = 0; i < N; i++)
17 {
18 if (pa[i] != (pb[i] * pc[i]))
19 abort ();
20 }
21
22 return;
23 }
24
25
26 __attribute__ ((noinline)) int
27 main1 (float *pa, float *pb, float *pc)
28 {
29 int i;
30 float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
31 float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
32
33 for (i = 0; i < N; i++)
34 {
35 b[i] = pb[i];
36 c[i] = pc[i];
37 }
38
39 /* Vectorizable: pa may not alias pb and/or pc, even though their
40 addresses escape. &pa would need to escape to point to escaped memory. */
41 for (i = 0; i < N; i++)
42 {
43 pa[i] = b[i] * c[i];
44 }
45
46 bar (pa,b,c);
47
48 return 0;
49 }
50
51 __attribute__ ((noinline)) int
52 main2 (float *pa, float *pb, float *pc)
53 {
54 int i;
55 float b[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
56 float c[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
57
58 for (i = 0; i < N; i++)
59 {
60 b[i] = pb[i];
61 c[i] = pc[i];
62 }
63
64 /* Vectorizable: pb and pc addresses do not escape. */
65 for (i = 0; i < N; i++)
66 {
67 pa[i] = b[i] * c[i];
68 }
69
70 /* check results: */
71 #pragma GCC novector
72 for (i = 0; i < N; i++)
73 {
74 if (pa[i] != (b[i] * c[i]))
75 abort ();
76 }
77
78 return 0;
79 }
80
81 int main (void)
82 {
83 int i;
84 float a[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
85 float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
86 float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
87
88 check_vect ();
89
90 main1 (a,b,c);
91 main2 (a,b,c);
92 return 0;
93 }
94
95 /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 2 "vect" } } */
96 /* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 6 "vect" { target { vect_no_align && { ! vect_hw_misalign } } } } } */