Use conditional internal functions in if-conversion
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / bmi2-pdep64-1.c
blob1268239e61f04495be971f01ec6c06a6d9f8b5c7
1 /* { dg-do run } */
2 /* { dg-options "-O3 -mcpu=power7" } */
3 /* { dg-require-effective-target lp64 } */
4 /* { dg-require-effective-target vsx_hw } */
5 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
6 /* { dg-require-effective-target ppc_cpu_supports_hw } */
8 #define NO_WARN_X86_INTRINSICS 1
9 #include <x86intrin.h>
10 #include "bmi2-check.h"
12 __attribute__((noinline))
13 unsigned long long
14 calc_pdep_u64 (unsigned long long a, unsigned long long mask)
16 unsigned long long res = 0;
17 unsigned long long i, k = 0;
19 for (i = 0; i < 64; ++i)
20 if (mask & (1LL << i)) {
21 res |= ((a & (1LL << k)) >> k) << i;
22 ++k;
24 return res;
27 static
28 void
29 bmi2_test ()
31 unsigned long long i;
32 unsigned long long src = 0xce7acce7acce7ac;
33 unsigned long long res, res_ref;
35 for (i = 0; i < 5; ++i) {
36 src = src * (i + 1);
38 res_ref = calc_pdep_u64 (src, ~(i * 3));
39 res = _pdep_u64 (src, ~(i * 3));
41 if (res != res_ref)
42 abort ();