| 1 |
/* { dg-require-effective-target vect_int } */ |
| 2 |
|
| 3 |
#include <stdarg.h> |
| 4 |
#include "tree-vect.h" |
| 5 |
|
| 6 |
#define N 64 |
| 7 |
|
| 8 |
unsigned char uX[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 9 |
unsigned short uresult[N]; |
| 10 |
signed char X[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); |
| 11 |
short result[N]; |
| 12 |
|
| 13 |
/* Unsigned type promotion (qi->hi) */ |
| 14 |
__attribute__ ((noinline)) int |
| 15 |
foo1(int len) { |
| 16 |
int i; |
| 17 |
|
| 18 |
for (i=0; i<len; i++) { |
| 19 |
uresult[i] = (unsigned short)uX[i]; |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
/* Signed type promotion (qi->hi) */ |
| 24 |
__attribute__ ((noinline)) int |
| 25 |
foo2(int len) { |
| 26 |
int i; |
| 27 |
|
| 28 |
for (i=0; i<len; i++) { |
| 29 |
result[i] = (short)X[i]; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
int main (void) |
| 34 |
{ |
| 35 |
int i; |
| 36 |
|
| 37 |
check_vect (); |
| 38 |
|
| 39 |
for (i=0; i<N; i++) { |
| 40 |
X[i] = 16-i; |
| 41 |
uX[i] = 16-i; |
| 42 |
__asm__ volatile (""); |
| 43 |
} |
| 44 |
|
| 45 |
foo1 (N); |
| 46 |
|
| 47 |
#pragma GCC novector |
| 48 |
for (i=0; i<N; i++) { |
| 49 |
if (uresult[i] != (unsigned short)uX[i]) |
| 50 |
abort (); |
| 51 |
} |
| 52 |
|
| 53 |
foo2 (N); |
| 54 |
|
| 55 |
#pragma GCC novector |
| 56 |
for (i=0; i<N; i++) { |
| 57 |
if (result[i] != (short)X[i]) |
| 58 |
abort (); |
| 59 |
} |
| 60 |
|
| 61 |
return 0; |
| 62 |
} |
| 63 |
|
| 64 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_unpack } } } */ |
| 65 |
|