| 1 |
/* Check that vector insertion works correctly. */ |
| 2 |
|
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-options "-msse" { target { i?86-*-* x86_64-*-* } } } */ |
| 5 |
/* { dg-require-effective-target sse_runtime { target { i?86-*-* x86_64-*-* } } } */ |
| 6 |
/* { dg-options "-mabi=altivec" { target { powerpc-*-* powerpc64-*-* } } } */ |
| 7 |
/* { dg-require-effective-target vmx_hw { target { powerpc-*-* powerpc64-*-* } } } */ |
| 8 |
|
| 9 |
#define vector __attribute__((vector_size(16) )) |
| 10 |
|
| 11 |
extern int memcmp (const void *, const void *, __SIZE_TYPE__); |
| 12 |
|
| 13 |
vector int f0(vector int t, int a) |
| 14 |
{ |
| 15 |
((int*)&t)[0] = a; |
| 16 |
return t; |
| 17 |
} |
| 18 |
vector int f1(vector int t, int a) |
| 19 |
{ |
| 20 |
((int*)&t)[1] = a; |
| 21 |
return t; |
| 22 |
} |
| 23 |
vector int f2(vector int t, int a) |
| 24 |
{ |
| 25 |
((int*)&t)[2] = a; |
| 26 |
return t; |
| 27 |
} |
| 28 |
vector int f3(vector int t, int a) |
| 29 |
{ |
| 30 |
((int*)&t)[3] = a; |
| 31 |
return t; |
| 32 |
} |
| 33 |
int main(void) |
| 34 |
{ |
| 35 |
vector int a = {0, 0, 0, 0}; |
| 36 |
vector int b = {1, 0, 0, 0}; |
| 37 |
vector int c = {0, 1, 0, 0}; |
| 38 |
vector int d = {0, 0, 1, 0}; |
| 39 |
vector int e = {0, 0, 0, 1}; |
| 40 |
vector int a0; |
| 41 |
a0 = f0(a, 1); |
| 42 |
if (memcmp (&a0, &b, sizeof(a0))) |
| 43 |
__builtin_abort (); |
| 44 |
a0 = f1(a, 1); |
| 45 |
if (memcmp (&a0, &c, sizeof(a0))) |
| 46 |
__builtin_abort (); |
| 47 |
a0 = f2(a, 1); |
| 48 |
if (memcmp (&a0, &d, sizeof(a0))) |
| 49 |
__builtin_abort (); |
| 50 |
a0 = f3(a, 1); |
| 51 |
if (memcmp (&a0, &e, sizeof(a0))) |
| 52 |
__builtin_abort (); |
| 53 |
return 0; |
| 54 |
} |