OSDN Git Service

2006-12-11 Diego Novillo <dnovillo@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vect / vect-multitypes-1.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 short sa[N];
9 short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
10                 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
11 int ia[N];
12 int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,
13                0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
14
15 /* Current peeling-for-alignment scheme will consider the 'sa[i+7]'
16    access for peeling, and therefore will examine the option of
17    using a peeling factor = VF-7%VF. This will result in a peeling factor 1,
18    which will also align the access to 'ia[i+3]', and the loop could be 
19    vectorized on all targets that support unaligned loads.
20  */
21
22 int main1 (int n)
23 {
24   int i;
25
26   /* Multiple types with different sizes, used in idependent
27      copmutations. Vectorizable.  */
28   for (i = 0; i < n; i++)
29     {
30       sa[i+7] = sb[i];
31       ia[i+3] = ib[i];
32     }
33
34   /* check results:  */
35   for (i = 0; i < n; i++)
36     {
37       if (sa[i+7] != sb[i] || ia[i+3] != ib[i])
38         abort ();
39     }
40
41   return 0;
42 }
43
44 /* Current peeling-for-alignment scheme will consider the 'ia[i+3]'
45    access for peeling, and therefore will examine the option of
46    using a peeling factor = VF-3%VF. This will result in a peeling factor
47    5 if VF=8, or 1 if VF=4,2. In either case, this will also align the access 
48    to 'sa[i+3]', and the loop could be vectorized on targets that support 
49    unaligned loads.  */
50
51 int main2 (int n)
52 {
53   int i;
54
55   /* Multiple types with different sizes, used in independent
56      copmutations. Vectorizable.  */
57   for (i = 0; i < n; i++)
58     {
59       ia[i+3] = ib[i];
60       sa[i+3] = sb[i];
61     }
62
63   /* check results:  */
64   for (i = 0; i < n; i++)
65     {
66       if (sa[i+3] != sb[i] || ia[i+3] != ib[i])
67         abort ();
68     }
69
70   return 0;
71 }
72
73 int main (void)
74
75   check_vect ();
76   
77   main1 (N-7);
78   main2 (N-3);
79
80   return 0;
81 }
82
83 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail vect_no_align } } } */
84 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail vect_no_align } } } */
85 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { xfail vect_no_align } } } */
86 /* { dg-final { cleanup-tree-dump "vect" } } */
87