Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-early-break_56.c

raw
1 /* { dg-add-options vect_early_break } */
2 /* Disabling epilogues until we find a better way to deal with scans. */
3 /* { dg-additional-options "--param vect-epilogues-nomask=0" } */
4 /* { dg-require-effective-target vect_int } */
5 /* { dg-add-options bind_pic_locally } */
6 /* { dg-require-effective-target vect_early_break_hw } */
7 /* { dg-require-effective-target vect_partial_vectors } */
8
9 #include <stdarg.h>
10 #include "tree-vect.h"
11
12 #define N 32
13
14 unsigned short sa[N];
15 unsigned short sc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
16 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
17 unsigned short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
18 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
19 unsigned int ia[N];
20 unsigned int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,
21 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
22 unsigned int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,
23 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
24
25 /* Current peeling-for-alignment scheme will consider the 'sa[i+7]'
26 access for peeling, and therefore will examine the option of
27 using a peeling factor = VF-7%VF. This will result in a peeling factor 1,
28 which will also align the access to 'ia[i+3]', and the loop could be
29 vectorized on all targets that support unaligned loads.
30 Without cost model on targets that support misaligned stores, no peeling
31 will be applied since we want to keep the four loads aligned. */
32
33 __attribute__ ((noinline))
34 int main1 ()
35 {
36 int i;
37 int n = N - 7;
38
39 /* Multiple types with different sizes, used in independent
40 copmutations. Vectorizable. */
41 for (i = 0; i < n; i++)
42 {
43 sa[i+7] = sb[i] + sc[i];
44 ia[i+3] = ib[i] + ic[i];
45 }
46
47 /* check results: */
48 for (i = 0; i < n; i++)
49 {
50 if (sa[i+7] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i])
51 abort ();
52 }
53
54 return 0;
55 }
56
57 /* Current peeling-for-alignment scheme will consider the 'ia[i+3]'
58 access for peeling, and therefore will examine the option of
59 using a peeling factor = VF-3%VF. This will result in a peeling factor
60 1 if VF=4,2. This will not align the access to 'sa[i+3]', for which we
61 need to peel 5,1 iterations for VF=4,2 respectively, so the loop can not
62 be vectorized. However, 'ia[i+3]' also gets aligned if we peel 5
63 iterations, so the loop is vectorizable on all targets that support
64 unaligned loads.
65 Without cost model on targets that support misaligned stores, no peeling
66 will be applied since we want to keep the four loads aligned. */
67
68 __attribute__ ((noinline))
69 int main2 ()
70 {
71 int i;
72 int n = N-3;
73
74 /* Multiple types with different sizes, used in independent
75 copmutations. Vectorizable. */
76 for (i = 0; i < n; i++)
77 {
78 ia[i+3] = ib[i] + ic[i];
79 sa[i+3] = sb[i] + sc[i];
80 }
81
82 /* check results: */
83 for (i = 0; i < n; i++)
84 {
85 if (sa[i+3] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i])
86 abort ();
87 }
88
89 return 0;
90 }
91
92 int main (void)
93 {
94 check_vect ();
95
96 main1 ();
97 main2 ();
98
99 return 0;
100 }
101
102 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail { vect_early_break && { ! vect_hw_misalign } } } } } */
103