Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-multitypes-4.c
blob7ac33672353071d1ab97f9e650966c4f9cb327e8
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 32
8 unsigned short sa[N];
9 unsigned short sc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
10 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
11 unsigned short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
12 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
13 unsigned int ia[N];
14 unsigned int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,
15 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
16 unsigned int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,
17 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
19 /* Current peeling-for-alignment scheme will consider the 'sa[i+7]'
20 access for peeling, and therefore will examine the option of
21 using a peeling factor = VF-7%VF. This will result in a peeling factor 1,
22 which will also align the access to 'ia[i+3]', and the loop could be
23 vectorized on all targets that support unaligned loads. */
25 __attribute__ ((noinline))
26 int main1 (int n)
28 int i;
30 /* Multiple types with different sizes, used in independent
31 copmutations. Vectorizable. */
32 for (i = 0; i < n; i++)
34 sa[i+7] = sb[i] + sc[i];
35 ia[i+3] = ib[i] + ic[i];
38 /* check results: */
39 for (i = 0; i < n; i++)
41 if (sa[i+7] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i])
42 abort ();
45 return 0;
48 /* Current peeling-for-alignment scheme will consider the 'ia[i+3]'
49 access for peeling, and therefore will examine the option of
50 using a peeling factor = VF-3%VF. This will result in a peeling factor
51 1 if VF=4,2. This will not align the access to 'sa[i+3]', for which we
52 need to peel 5,1 iterations for VF=4,2 respectively, so the loop can not
53 be vectorized. */
55 __attribute__ ((noinline))
56 int main2 (int n)
58 int i;
60 /* Multiple types with different sizes, used in independent
61 copmutations. Vectorizable. */
62 for (i = 0; i < n; i++)
64 ia[i+3] = ib[i] + ic[i];
65 sa[i+3] = sb[i] + sc[i];
68 /* check results: */
69 for (i = 0; i < n; i++)
71 if (sa[i+3] != sb[i] + sc[i] || ia[i+3] != ib[i] + ic[i])
72 abort ();
75 return 0;
78 int main (void)
80 check_vect ();
82 main1 (N-7);
83 main2 (N-3);
85 return 0;
88 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail *-*-* } } } */
89 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_align } } } */
90 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail *-*-* } } } */
91 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail vect_no_align } } } */
92 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 8 "vect" { xfail *-*-* } } } */
93 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { xfail vect_no_align } } } */
94 /* { dg-final { cleanup-tree-dump "vect" } } */