Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / bmi2-pdep32-1.c
blob7e0ca4772fb73a36c1560659557f8942ebb1394b
1 /* { dg-do run { target bmi2 } } */
2 /* { dg-options "-mbmi2 -O2" } */
4 #include <x86intrin.h>
5 #include "bmi2-check.h"
7 __attribute__((noinline))
8 unsigned
9 calc_pdep_u32 (unsigned a, int mask)
11 unsigned res = 0;
12 int i, k = 0;
14 for (i = 0; i < 32; ++i)
15 if (mask & (1 << i)) {
16 res |= ((a & (1 << k)) >> k) << i;
17 ++k;
20 return res;
23 static void
24 bmi2_test ()
26 unsigned i;
27 unsigned src = 0xce7acc;
28 unsigned res, res_ref;
30 for (i = 0; i < 5; ++i) {
31 src = src * (i + 1);
33 res_ref = calc_pdep_u32 (src, i * 3);
34 res = _pdep_u32 (src, i * 3);
36 if (res != res_ref)
37 abort();