| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target lp64 } */ |
| 3 |
/* { dg-options "-O3 -msse2" } */ |
| 4 |
|
| 5 |
typedef long v2di __attribute__((vector_size(16))); |
| 6 |
typedef int v4si __attribute__((vector_size(16))); |
| 7 |
|
| 8 |
void foo (v4si *p, v2di *q) |
| 9 |
{ |
| 10 |
union { v2di a; v4si b; } u; |
| 11 |
u.a = *q; |
| 12 |
(*p)[0] = u.b[0]; |
| 13 |
(*p)[1] = u.b[2]; |
| 14 |
(*p)[2] = u.b[1]; |
| 15 |
(*p)[3] = u.b[3]; |
| 16 |
} |
| 17 |
|
| 18 |
void bar (v4si *p, __int128_t *q) |
| 19 |
{ |
| 20 |
union { __int128_t a; v4si b; } u; |
| 21 |
u.a = *q; |
| 22 |
(*p)[0] = u.b[1]; |
| 23 |
(*p)[1] = u.b[2]; |
| 24 |
(*p)[2] = u.b[1]; |
| 25 |
(*p)[3] = u.b[3]; |
| 26 |
} |
| 27 |
|
| 28 |
/* Both functions should end up with sth like |
| 29 |
[v]pshufd $val, (%esi), %xmm0 |
| 30 |
[v]movdqa %xmm0, (%edi) |
| 31 |
ret |
| 32 |
recognized by SLP vectorization involving an existing "vector". */ |
| 33 |
/* { dg-final { scan-assembler-not "punpck" } } */ |
| 34 |
/* { dg-final { scan-assembler-times "pshufd" 2 } } */ |