[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / bmi2-pdep64-1.c
blob549fbaa1ab2040e01b4d4fc7754157efe2c51e29
1 /* { dg-do run } */
2 /* { dg-options "-O3 -mdejagnu-cpu=power7" } */
3 /* { dg-require-effective-target lp64 } */
4 /* { dg-require-effective-target vsx_hw } */
5 /* { dg-require-effective-target ppc_cpu_supports_hw } */
7 #define NO_WARN_X86_INTRINSICS 1
8 #include <x86intrin.h>
9 #include "bmi2-check.h"
11 __attribute__((noinline))
12 unsigned long long
13 calc_pdep_u64 (unsigned long long a, unsigned long long mask)
15 unsigned long long res = 0;
16 unsigned long long i, k = 0;
18 for (i = 0; i < 64; ++i)
19 if (mask & (1LL << i)) {
20 res |= ((a & (1LL << k)) >> k) << i;
21 ++k;
23 return res;
26 static
27 void
28 bmi2_test ()
30 unsigned long long i;
31 unsigned long long src = 0xce7acce7acce7ac;
32 unsigned long long res, res_ref;
34 for (i = 0; i < 5; ++i) {
35 src = src * (i + 1);
37 res_ref = calc_pdep_u64 (src, ~(i * 3));
38 res = _pdep_u64 (src, ~(i * 3));
40 if (res != res_ref)
41 abort ();