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. */
calc_blsi_u64(long long src1,long long src2)11 long long calc_blsi_u64 (long long src1, long long src2)
12 {
13   return (-src1) & (src2);
14 }
15 
16 static void
bmi_test()17 bmi_test()
18 {
19   unsigned i;
20 
21   long long src = 0xfacec0ffeefacec0;
22   long long res, res_ref;
23 
24   for (i=0; i<5; ++i) {
25     src = (i + src) << i;
26 
27     res_ref = calc_blsi_u64 (src, src);
28     res = __blsi_u64 (src);
29 
30     if (res != res_ref)
31       abort();
32   }
33 }
34