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