OSDN Git Service

* gcc.dg/vect/vect-116.c: Add vect_int target requirement.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-multitypes-6.c
1 /* { dg-require-effective-target vect_int } */
2
3 #include <stdarg.h>
4 #include "tree-vect.h"
5
6 #define N 32
7
8 unsigned int ic[N] __attribute__ ((__aligned__(16))) = 
9         {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
10 unsigned int ib[N] __attribute__ ((__aligned__(16))) = 
11         {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
12 unsigned short sc[N] __attribute__ ((__aligned__(16))) = 
13         {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
14 unsigned short sb[N] __attribute__ ((__aligned__(16))) = 
15         {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
16 unsigned char cc[N] __attribute__ ((__aligned__(16))) = 
17         {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
18 unsigned char cb[N] __attribute__ ((__aligned__(16))) = 
19         {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
20
21 int main1 (int n, 
22            unsigned int * __restrict__ pic, unsigned int * __restrict__ pib, 
23            unsigned short * __restrict__ psc, unsigned short * __restrict__ psb,
24            unsigned char * __restrict__ pcc, unsigned char * __restrict__ pcb)
25 {
26   int i;
27   unsigned int ia[N];
28   unsigned short sa[N];
29   unsigned char ca[N];
30
31   /* Multiple types with different sizes, used in independent
32      computations. Vectorizable. The loads are misaligned.  */
33   for (i = 0; i < n; i++)
34     {
35       ia[i] = pib[i] + pic[i];
36       sa[i] = psb[i] + psc[i];
37       ca[i] = pcb[i] + pcc[i];
38     }
39
40   /* check results:  */
41   for (i = 0; i < n; i++)
42     {
43       if (ia[i] != pib[i] + pic[i] 
44           || sa[i] != psb[i] + psc[i] 
45           || ca[i] != pcb[i] + pcc[i])
46         abort ();
47     }
48
49   return 0;
50 }
51
52 int main (void)
53
54   check_vect ();
55   
56   main1 (N, ic, ib, sc, sb, cc, cb);
57   main1 (N-3, ic, ib, &sc[1], sb, cc, &cb[2]);
58   return 0;
59 }
60
61 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
62 /*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 6 "vect" { target vect_no_align } } } */
63 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 6 "vect" {xfail vect_no_align } } } */
64 /* { dg-final { cleanup-tree-dump "vect" } } */
65