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