| 1 |
/* Disabling epilogues until we find a better way to deal with scans. */ |
| 2 |
/* { dg-additional-options "--param vect-epilogues-nomask=0 -fdump-tree-optimized-details-blocks" } */ |
| 3 |
/* { dg-require-effective-target vect_float } */ |
| 4 |
|
| 5 |
#include <stdarg.h> |
| 6 |
#include "tree-vect.h" |
| 7 |
|
| 8 |
#define N 256 |
| 9 |
|
| 10 |
float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 11 |
float pb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; |
| 12 |
float pc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; |
| 13 |
|
| 14 |
/* Check handling of unaligned accesses when the misalignment is |
| 15 |
known at compile time and different accesses have the same |
| 16 |
misalignment (e.g. peeling to align one access will align all |
| 17 |
accesses with the same misalignment. Also, the number of |
| 18 |
peeled iterations is known in this case, and the vectorizer |
| 19 |
can use this information (generate prolog and epilog loops |
| 20 |
with known number of iterations, and only if needed). */ |
| 21 |
|
| 22 |
#if VECTOR_BITS > 128 |
| 23 |
#define NITER (VECTOR_BITS * 3 / 32) |
| 24 |
#else |
| 25 |
#define NITER 12 |
| 26 |
#endif |
| 27 |
|
| 28 |
__attribute__ ((noinline)) int |
| 29 |
main1 () |
| 30 |
{ |
| 31 |
int i; |
| 32 |
|
| 33 |
for (i = 0; i < NITER - 2; i++) |
| 34 |
{ |
| 35 |
pa[i+1] = pb[i+1] * pc[i+1]; |
| 36 |
} |
| 37 |
|
| 38 |
/* check results: */ |
| 39 |
#pragma GCC novector |
| 40 |
for (i = 0; i < 10; i++) |
| 41 |
{ |
| 42 |
if (pa[i+1] != (pb[i+1] * pc[i+1])) |
| 43 |
abort (); |
| 44 |
} |
| 45 |
|
| 46 |
return 0; |
| 47 |
} |
| 48 |
|
| 49 |
__attribute__ ((noinline)) int |
| 50 |
main2 () |
| 51 |
{ |
| 52 |
int i; |
| 53 |
|
| 54 |
for (i = 0; i < NITER; i++) |
| 55 |
{ |
| 56 |
pa[i+1] = pb[i+1] * pc[i+1]; |
| 57 |
} |
| 58 |
|
| 59 |
/* check results: */ |
| 60 |
#pragma GCC novector |
| 61 |
for (i = 0; i < 12; i++) |
| 62 |
{ |
| 63 |
if (pa[i+1] != (pb[i+1] * pc[i+1])) |
| 64 |
abort (); |
| 65 |
} |
| 66 |
|
| 67 |
return 0; |
| 68 |
} |
| 69 |
|
| 70 |
__attribute__ ((noinline)) int |
| 71 |
main3 (int n) |
| 72 |
{ |
| 73 |
int i; |
| 74 |
|
| 75 |
for (i = 0; i < n; i++) |
| 76 |
{ |
| 77 |
pa[i+1] = pb[i+1] * pc[i+1]; |
| 78 |
} |
| 79 |
|
| 80 |
/* check results: */ |
| 81 |
#pragma GCC novector |
| 82 |
for (i = 0; i < n; i++) |
| 83 |
{ |
| 84 |
if (pa[i+1] != (pb[i+1] * pc[i+1])) |
| 85 |
abort (); |
| 86 |
} |
| 87 |
|
| 88 |
return 0; |
| 89 |
} |
| 90 |
|
| 91 |
int main (void) |
| 92 |
{ |
| 93 |
int i; |
| 94 |
|
| 95 |
check_vect (); |
| 96 |
|
| 97 |
main1 (); |
| 98 |
main2 (); |
| 99 |
main3 (N-1); |
| 100 |
|
| 101 |
return 0; |
| 102 |
} |
| 103 |
|
| 104 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */ |
| 105 |
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ |
| 106 |
/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 3 "vect" { xfail vect_element_align_preferred } } } */ |
| 107 |
/* { dg-final { scan-tree-dump-not "Invalid sum" "optimized" } } */ |