| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O3 -fno-inline" } */ |
| 3 |
/* { dg-require-effective-target lp64 } */ |
| 4 |
/* { dg-require-effective-target ppc_cpu_supports_hw } */ |
| 5 |
|
| 6 |
#define NO_WARN_X86_INTRINSICS 1 |
| 7 |
#include <x86intrin.h> |
| 8 |
#include "bmi-check.h" |
| 9 |
|
| 10 |
/* To fool the compiler, so it does not generate blsi here. */ |
| 11 |
int calc_blsi_u32 (int src1, int src2) |
| 12 |
{ |
| 13 |
return (-src1) & (src2); |
| 14 |
} |
| 15 |
|
| 16 |
static void |
| 17 |
bmi_test() |
| 18 |
{ |
| 19 |
unsigned i; |
| 20 |
int src = 0xfacec0ff; |
| 21 |
int res, res_ref; |
| 22 |
|
| 23 |
for (i=0; i<5; ++i) { |
| 24 |
src = (i + src) << i; |
| 25 |
|
| 26 |
res_ref = calc_blsi_u32 (src, src); |
| 27 |
res = __blsi_u32 (src); |
| 28 |
|
| 29 |
if (res != res_ref) |
| 30 |
abort(); |
| 31 |
} |
| 32 |
} |