| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
/* { dg-require-effective-target vect_shift } */ |
| 3 |
/* { dg-require-effective-target vect_pack_trunc } */ |
| 4 |
/* { dg-require-effective-target vect_unpack } */ |
| 5 |
|
| 6 |
#include "tree-vect.h" |
| 7 |
|
| 8 |
#define N 111 |
| 9 |
|
| 10 |
/* This shouldn't be treated as an over-widening operation: it's better |
| 11 |
to reuse the extensions of di and ei for di + ei than to add them |
| 12 |
as shorts and introduce a third extension. */ |
| 13 |
|
| 14 |
void __attribute__ ((noipa)) |
| 15 |
f (unsigned int *restrict a, unsigned int *restrict b, |
| 16 |
unsigned int *restrict c, unsigned char *restrict d, |
| 17 |
unsigned char *restrict e) |
| 18 |
{ |
| 19 |
for (__INTPTR_TYPE__ i = 0; i < N; ++i) |
| 20 |
{ |
| 21 |
int di = d[i]; |
| 22 |
int ei = e[i]; |
| 23 |
a[i] = di; |
| 24 |
b[i] = ei; |
| 25 |
c[i] = di + ei; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
int |
| 30 |
main (void) |
| 31 |
{ |
| 32 |
check_vect (); |
| 33 |
|
| 34 |
unsigned int a[N], b[N], c[N]; |
| 35 |
unsigned char d[N], e[N]; |
| 36 |
for (int i = 0; i < N; ++i) |
| 37 |
{ |
| 38 |
d[i] = i * 2 + 3; |
| 39 |
e[i] = i + 100; |
| 40 |
asm volatile ("" ::: "memory"); |
| 41 |
} |
| 42 |
f (a, b, c, d, e); |
| 43 |
#pragma GCC novector |
| 44 |
for (int i = 0; i < N; ++i) |
| 45 |
if (a[i] != i * 2 + 3 |
| 46 |
|| b[i] != i + 100 |
| 47 |
|| c[i] != i * 3 + 103) |
| 48 |
__builtin_abort (); |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |
| 52 |
|
| 53 |
/* { dg-final { scan-tree-dump-not {vect_recog_over_widening_pattern: detected} "vect" } } */ |
| 54 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */ |