| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-skip-if "" { powerpc*-*-darwin* } } */ |
| 3 |
/* { dg-options "-O3 -mdejagnu-cpu=power7" } */ |
| 4 |
/* { dg-require-effective-target lp64 } */ |
| 5 |
/* { dg-require-effective-target powerpc_vsx } */ |
| 6 |
|
| 7 |
#define NO_WARN_X86_INTRINSICS 1 |
| 8 |
#include <x86intrin.h> |
| 9 |
|
| 10 |
unsigned long long |
| 11 |
test__pexp_cmask_u64 (unsigned long long a[4]) |
| 12 |
{ |
| 13 |
/* The _pext implmentation is nominally a popcount of the mask, |
| 14 |
followed by a loop using count leading zeros to find the |
| 15 |
next bit to process. |
| 16 |
If the mask is a const, the popcount should be folded and |
| 17 |
the constant propagation should eliminate the mask |
| 18 |
generation loop and produce a single constant bpermd permute |
| 19 |
control word. |
| 20 |
This test verifies that the compiler is replacing the mask |
| 21 |
popcount and loop with a const bperm control and generating |
| 22 |
the bpermd for this case. */ |
| 23 |
const unsigned long mask = 0x00000000100000a4UL; |
| 24 |
unsigned long res; |
| 25 |
res = _pext_u64 (a[0], mask); |
| 26 |
res = (res << 8) | _pext_u64 (a[1], mask); |
| 27 |
res = (res << 8) | _pext_u64 (a[2], mask); |
| 28 |
res = (res << 8) | _pext_u64 (a[3], mask); |
| 29 |
return (res); |
| 30 |
} |
| 31 |
/* the resulting assembler should have 4 X bpermd and no popcntd or |
| 32 |
cntlzd instructions. */ |
| 33 |
|
| 34 |
/* { dg-final { scan-assembler-times "bpermd" 4 } } */ |
| 35 |
/* { dg-final { scan-assembler-not "popcntd" } } */ |
| 36 |
/* { dg-final { scan-assembler-not "cntlzd" } } */ |