Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-multitypes-4.c

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