| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
/* { dg-require-effective-target vect_perm } */ |
| 3 |
|
| 4 |
#include <stdarg.h> |
| 5 |
#include "tree-vect.h" |
| 6 |
|
| 7 |
#define N 32 |
| 8 |
|
| 9 |
unsigned int ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45, |
| 10 |
0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; |
| 11 |
unsigned int uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, |
| 12 |
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; |
| 13 |
|
| 14 |
/* Vectorization of reduction using loop-aware SLP (with two copies). */ |
| 15 |
|
| 16 |
__attribute__ ((noinline)) |
| 17 |
int main1 (int n, int res0, int res1, int res2, int res3, |
| 18 |
int res4, int res5, int res6, int res7) |
| 19 |
{ |
| 20 |
int i; |
| 21 |
unsigned int udiff0 = 5, udiff1 = 10, udiff2 = 20, udiff3 = 30; |
| 22 |
unsigned int udiff4 = 45, udiff5 = 50, udiff6 = 60, udiff7 = 70; |
| 23 |
|
| 24 |
for (i = 0; i < n; i++) { |
| 25 |
udiff7 += (ub[8*i + 7] - uc[8*i + 7]); |
| 26 |
udiff6 += (ub[8*i + 6] - uc[8*i + 6]); |
| 27 |
udiff5 += (ub[8*i + 5] - uc[8*i + 5]); |
| 28 |
udiff4 += (ub[8*i + 4] - uc[8*i + 4]); |
| 29 |
udiff3 += (ub[8*i + 3] - uc[8*i + 3]); |
| 30 |
udiff2 += (ub[8*i + 2] - uc[8*i + 2]); |
| 31 |
udiff1 += (ub[8*i + 1] - uc[8*i + 1]); |
| 32 |
udiff0 += (ub[8*i] - uc[8*i]); |
| 33 |
} |
| 34 |
|
| 35 |
/* Check results: */ |
| 36 |
if (udiff0 != res0 |
| 37 |
|| udiff1 != res1 |
| 38 |
|| udiff2 != res2 |
| 39 |
|| udiff3 != res3 |
| 40 |
|| udiff4 != res4 |
| 41 |
|| udiff5 != res5 |
| 42 |
|| udiff6 != res6 |
| 43 |
|| udiff7 != res7) |
| 44 |
abort (); |
| 45 |
|
| 46 |
return 0; |
| 47 |
} |
| 48 |
|
| 49 |
int main (void) |
| 50 |
{ |
| 51 |
check_vect (); |
| 52 |
|
| 53 |
main1 (N/8, 37, 50, 68, 86, 109, 122, 140, 158); |
| 54 |
main1 (N/8 - 1, 21, 32, 48, 64, 85, 96, 112, 128); |
| 55 |
return 0; |
| 56 |
} |
| 57 |
|
| 58 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail vect_no_int_add } } } */ |
| 59 |
/* For variable-length SVE, the number of scalar statements in the |
| 60 |
reduction exceeds the number of elements in a 128-bit granule. */ |
| 61 |
/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { xfail { vect_no_int_add || { { aarch64_sve && vect_variable_length } || { riscv_v && vect_variable_length } } } } } } */ |
| 62 |
/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 0 "vect" { xfail { aarch64_sve && vect_variable_length } } } } */ |