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