2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-109.c
blob9a5071058991fb9f855038132fcddd83d6057ef9
1 /* { dg-skip-if "" { vect_no_align } } */
2 /* { dg-require-effective-target vect_int } */
3 /* { dg-add-options bind_pic_locally } */
5 #include <stdarg.h>
6 #include "tree-vect.h"
8 #define N 32
10 short sa[N];
11 short sc[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 short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
14 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
15 int ia[N];
16 int ic[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};
18 int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,
19 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
21 __attribute__ ((noinline))
22 int main1 (int n)
24 int i;
26 /* Multiple types with different sizes, used in idependent
27 copmutations. Vectorizable. */
28 for (i = 0; i < n; i++)
30 sa[i+2] = sb[i] + sc[i];
31 ia[i+1] = ib[i] + ic[i];
34 /* check results: */
35 for (i = 0; i < n; i++)
37 if (sa[i+2] != sb[i] + sc[i] || ia[i+1] != ib[i] + ic[i])
38 abort ();
41 return 0;
44 int main2 (int n)
46 int i;
48 /* Multiple types with different sizes, used in idependent
49 copmutations. Vectorizable. */
50 for (i = 0; i < n; i++)
52 ia[i+1] = ib[i] + ic[i];
53 sa[i] = sb[i] + sc[i];
56 /* check results: */
57 for (i = 0; i < n; i++)
59 if (sa[i] != sb[i] + sc[i] || ia[i+1] != ib[i] + ic[i])
60 abort ();
63 return 0;
67 int main (void)
69 check_vect ();
71 main1 (N-2);
72 main2 (N-1);
74 return 0;
77 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_element_align } } } */
78 /* { dg-final { scan-tree-dump-times "not vectorized: unsupported unaligned store" 2 "vect" { xfail vect_element_align } } } */
79 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" { target vect_element_align xfail { ! vect_unaligned_possible } } } } */