Imported Upstream version 4.7.3
[platform/upstream/gcc48.git] / gcc / testsuite / gcc.dg / vect / vect-multitypes-3.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 int ib[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 short sb[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 char cb[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
16 __attribute__ ((noinline)) 
17 int main1 (int n, int * __restrict__ pib, 
18            short * __restrict__ psb, 
19            char * __restrict__ pcb)
20 {
21   int i;
22   int ia[N];
23   short sa[N];
24   char ca[N];
25
26   /* Multiple types with different sizes, used in independent
27      computations. Vectorizable. The loads are misaligned.  */
28   for (i = 0; i < n; i++)
29     {
30       ia[i] = pib[i];
31       sa[i] = psb[i];
32       ca[i] = pcb[i];
33     }
34
35   /* check results:  */
36   for (i = 0; i < n; i++)
37     {
38       if (ia[i] != pib[i] 
39           || sa[i] != psb[i] 
40           || ca[i] != pcb[i])
41         abort ();
42     }
43
44   return 0;
45 }
46
47 int main (void)
48
49   check_vect ();
50   
51   main1 (N, ib, sb, cb);
52   main1 (N-3, ib, sb, &cb[2]);
53   return 0;
54 }
55
56 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
57 /*  { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 3 "vect" { target vect_no_align } } } */
58 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 3 "vect" {xfail { vect_no_align } } } } */
59 /* { dg-final { cleanup-tree-dump "vect" } } */
60