1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_pack_trunc } */
3 /* { dg-require-effective-target vect_unpack } */
4 /* { dg-require-effective-target vect_hw_misalign } */
5
6 #include "tree-vect.h"
7
8 void __attribute__((noinline,noclone))
testi(int * p,short * q,int stride,int n)9 testi (int *p, short *q, int stride, int n)
10 {
11 int i;
12 for (i = 0; i < n; ++i)
13 {
14 q[i*4+0] = p[i*stride+0];
15 q[i*4+1] = p[i*stride+1];
16 q[i*4+2] = p[i*stride+2];
17 q[i*4+3] = p[i*stride+3];
18 }
19 }
20
21 void __attribute__((noinline,noclone))
testi2(int * q,short * p,int stride,int n)22 testi2 (int *q, short *p, int stride, int n)
23 {
24 int i;
25 for (i = 0; i < n; ++i)
26 {
27 q[i*4+0] = p[i*stride+0];
28 q[i*4+1] = p[i*stride+1];
29 q[i*4+2] = p[i*stride+2];
30 q[i*4+3] = p[i*stride+3];
31 }
32 }
33
34 int ia[256];
35 short sa[256];
36
37 extern void abort (void);
38
main()39 int main()
40 {
41 int i;
42
43 check_vect ();
44
45 for (i = 0; i < 256; ++i)
46 {
47 ia[i] = sa[i] = i;
48 __asm__ volatile ("");
49 }
50 testi (ia, sa, 8, 32);
51 for (i = 0; i < 128; ++i)
52 if (sa[i] != ia[(i / 4) * 8 + i % 4])
53 abort ();
54
55 for (i = 0; i < 256; ++i)
56 {
57 ia[i] = sa[i] = i;
58 __asm__ volatile ("");
59 }
60 testi2 (ia, sa, 8, 32);
61 for (i = 0; i < 128; ++i)
62 if (ia[i] != sa[(i / 4) * 8 + i % 4])
63 abort ();
64
65 return 0;
66 }
67
68 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" } } */
69