2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-multitypes-1.c
blob1a0375266b07d9a175cd89618b2c8330889262f1
1 /* { dg-require-effective-target vect_int } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 32
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};
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 = V-7%V = 1,3 for V=8,4 respectively,
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. */
21 __attribute__ ((noinline)) int main1 (int n)
23 int i;
25 /* Multiple types with different sizes, used in idependent
26 copmutations. Vectorizable. */
27 for (i = 0; i < n; i++)
29 sa[i+7] = sb[i];
30 ia[i+3] = ib[i];
33 /* check results: */
34 for (i = 0; i < n; i++)
36 if (sa[i+7] != sb[i] || ia[i+3] != ib[i])
37 abort ();
40 return 0;
43 /* Current peeling-for-alignment scheme will consider the 'ia[i+3]'
44 access for peeling, and therefore will examine the option of
45 using a peeling factor = (V-3)%V = 1 for V=2,4.
46 This will not align the access 'sa[i+3]' (for which we need to
47 peel 5 iterations), so the loop can not be vectorized. */
49 __attribute__ ((noinline)) int main2 (int n)
51 int i;
53 /* Multiple types with different sizes, used in independent
54 copmutations. */
55 for (i = 0; i < n; i++)
57 ia[i+3] = ib[i];
58 sa[i+3] = sb[i];
61 /* check results: */
62 for (i = 0; i < n; i++)
64 if (sa[i+3] != sb[i] || ia[i+3] != ib[i])
65 abort ();
68 return 0;
71 int main (void)
73 check_vect ();
75 main1 (N-7);
76 main2 (N-3);
78 return 0;
81 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail {! vect_hw_misalign} } } } */
82 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail { vect_no_align || vect_hw_misalign } } } } */
83 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail *-*-* } } } */
84 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { xfail { vect_no_align || vect_hw_misalign }} } } */
85 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { xfail {! vect_hw_misalign} } } } */
86 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail { vect_no_align || vect_hw_misalign } } } } */
87 /* { dg-final { cleanup-tree-dump "vect" } } */