1 /* See if various BMI2 instructions give expected results */
5 int main(int argc
, char *argv
[]) {
6 uint64_t ehlo
= 0x202020204f4c4845ull
;
7 uint64_t mask
= 0xa080800302020001ull
;
14 asm volatile ("pextq %2, %1, %0" : "=r"(result64
) : "r"(ehlo
), "m"(mask
));
15 assert(result64
== 133);
17 asm volatile ("pdepq %2, %1, %0" : "=r"(result64
) : "r"(result64
), "m"(mask
));
18 assert(result64
== (ehlo
& mask
));
20 asm volatile ("pextq %2, %1, %0" : "=r"(result64
) : "r"(-1ull), "m"(mask
));
21 assert(result64
== 511); /* mask has 9 bits set */
23 asm volatile ("pdepq %2, %1, %0" : "=r"(result64
) : "r"(-1ull), "m"(mask
));
24 assert(result64
== mask
);
28 asm volatile ("pextl %2, %k1, %k0" : "=r"(result32
) : "r"((uint32_t) ehlo
), "m"(mask
));
29 assert(result32
== 5);
31 asm volatile ("pdepl %2, %k1, %k0" : "=r"(result32
) : "r"(result32
), "m"(mask
));
32 assert(result32
== (uint32_t)(ehlo
& mask
));
34 asm volatile ("pextl %2, %k1, %k0" : "=r"(result32
) : "r"(-1ull), "m"(mask
));
35 assert(result32
== 7); /* mask has 3 bits set */
37 asm volatile ("pdepl %2, %k1, %k0" : "=r"(result32
) : "r"(-1ull), "m"(mask
));
38 assert(result32
== (uint32_t)mask
);