| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
/* { dg-add-options bind_pic_locally } */ |
| 3 |
|
| 4 |
#include <stdarg.h> |
| 5 |
#include "tree-vect.h" |
| 6 |
|
| 7 |
#if VECTOR_BITS > 128 |
| 8 |
#define NSHORTS (VECTOR_BITS / 16) |
| 9 |
#else |
| 10 |
#define NSHORTS 8 |
| 11 |
#endif |
| 12 |
|
| 13 |
#define NINTS (NSHORTS / 2) |
| 14 |
#define N (NSHORTS * 4) |
| 15 |
|
| 16 |
short sa[N]; |
| 17 |
short sb[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, |
| 18 |
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}; |
| 19 |
int ia[N]; |
| 20 |
int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, |
| 21 |
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; |
| 22 |
|
| 23 |
/* Current peeling-for-alignment scheme will consider the 'sa[i+7]' |
| 24 |
access for peeling, and therefore will examine the option of |
| 25 |
using a peeling factor = V-7%V = 1,3 for V=8,4 respectively, |
| 26 |
which will also align the access to 'ia[i+3]', and the loop could be |
| 27 |
vectorized on all targets that support unaligned loads. */ |
| 28 |
|
| 29 |
__attribute__ ((noinline)) int main1 (int n) |
| 30 |
{ |
| 31 |
int i; |
| 32 |
|
| 33 |
/* Multiple types with different sizes, used in idependent |
| 34 |
copmutations. Vectorizable. */ |
| 35 |
for (i = 0; i < n; i++) |
| 36 |
{ |
| 37 |
sa[i + NSHORTS - 1] = sb[i]; |
| 38 |
ia[i + NINTS - 1] = ib[i + 1]; |
| 39 |
} |
| 40 |
|
| 41 |
/* check results: */ |
| 42 |
#pragma GCC novector |
| 43 |
for (i = 0; i < n; i++) |
| 44 |
{ |
| 45 |
if (sa[i + NSHORTS - 1] != sb[i] || ia[i + NINTS - 1] != ib[i + 1]) |
| 46 |
abort (); |
| 47 |
} |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |
| 51 |
|
| 52 |
/* Current peeling-for-alignment scheme will consider the 'ia[i+3]' |
| 53 |
access for peeling, and therefore will examine the option of |
| 54 |
using a peeling factor = (V-3)%V = 1 for V=2,4. |
| 55 |
This will not align the access 'sa[i+3]' (for which we need to |
| 56 |
peel 5 iterations). However, 'ia[i+3]' also gets aligned if we peel 5 |
| 57 |
iterations, so the loop is vectorizable on all targets that support |
| 58 |
unaligned loads. */ |
| 59 |
|
| 60 |
__attribute__ ((noinline)) int main2 (int n) |
| 61 |
{ |
| 62 |
int i; |
| 63 |
|
| 64 |
/* Multiple types with different sizes, used in independent |
| 65 |
copmutations. */ |
| 66 |
for (i = 0; i < n; i++) |
| 67 |
{ |
| 68 |
ia[i + NINTS - 1] = ib[i]; |
| 69 |
sa[i + NINTS - 1] = sb[i + 1]; |
| 70 |
} |
| 71 |
|
| 72 |
/* check results: */ |
| 73 |
#pragma GCC novector |
| 74 |
for (i = 0; i < n; i++) |
| 75 |
{ |
| 76 |
if (sa[i + NINTS - 1] != sb[i + 1] || ia[i + NINTS - 1] != ib[i]) |
| 77 |
abort (); |
| 78 |
} |
| 79 |
|
| 80 |
return 0; |
| 81 |
} |
| 82 |
|
| 83 |
int main (void) |
| 84 |
{ |
| 85 |
check_vect (); |
| 86 |
|
| 87 |
main1 (N - NSHORTS + 1); |
| 88 |
main2 (N - NINTS + 1); |
| 89 |
|
| 90 |
return 0; |
| 91 |
} |
| 92 |
|
| 93 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */ |
| 94 |
/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail { { ! vect_unaligned_possible } || vect_sizes_32B_16B } } } } */ |
| 95 |
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { target { vect_no_align && { { ! vect_hw_misalign } && vect_sizes_32B_16B } } }} } */ |
| 96 |
|