OSDN Git Service

PR tree-optimization/40542
[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__(__BIGGEST_ALIGNMENT__))) = 
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__(__BIGGEST_ALIGNMENT__))) = 
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__(__BIGGEST_ALIGNMENT__))) = 
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__(__BIGGEST_ALIGNMENT__))) = 
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__(__BIGGEST_ALIGNMENT__))) = 
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__(__BIGGEST_ALIGNMENT__))) = 
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 __attribute__ ((noinline))
22 int main1 (int n, 
23            unsigned int * __restrict__ pic, unsigned int * __restrict__ pib, 
24            unsigned short * __restrict__ psc, unsigned short * __restrict__ psb,
25            unsigned char * __restrict__ pcc, unsigned char * __restrict__ pcb)
26 {
27   int i;
28   unsigned int ia[N];
29   unsigned short sa[N];
30   unsigned char ca[N];
31
32   /* Multiple types with different sizes, used in independent
33      computations. Vectorizable. The loads are misaligned.  */
34   for (i = 0; i < n; i++)
35     {
36       ia[i] = pib[i] + pic[i];
37       sa[i] = psb[i] + psc[i];
38       ca[i] = pcb[i] + pcc[i];
39     }
40
41   /* check results:  */
42   for (i = 0; i < n; i++)
43     {
44       if (ia[i] != pib[i] + pic[i] 
45           || sa[i] != psb[i] + psc[i] 
46           || ca[i] != pcb[i] + pcc[i])
47         abort ();
48     }
49
50   return 0;
51 }
52
53 int main (void)
54
55   check_vect ();
56   
57   main1 (N, ic, ib, sc, sb, cc, cb);
58   main1 (N-3, ic, ib, &sc[1], sb, cc, &cb[2]);
59   return 0;
60 }
61
62 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
63 /*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 6 "vect" { target vect_no_align } } } */
64 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 6 "vect" {xfail vect_no_align } } } */
65 /* { dg-final { cleanup-tree-dump "vect" } } */
66