5 static void check_popcnt(uint64_t in
, uint64_t expected_result
,
8 uint64_t out
= ~expected_result
;
11 asm volatile(".insn rre, 0xb9e10000, %[out], %[in]\n\t"
14 : [cc
]"=d" (cc
), [out
]"=d" (out
)
17 printf("popcnt %16lx -> %16lx %s cc=%d %s\n",
18 in
, out
, (out
== expected_result
? " " : "ERR"),
19 cc
, (cc
== expected_cc
? " " : "ERR"));
24 check_popcnt(0, 0, 0);
25 check_popcnt(1, 1, 1);
26 check_popcnt(0x8000000000000000ULL
, 0x0100000000000000ULL
, 1);
27 check_popcnt(0xffffffffffffffffULL
, 0x0808080808080808ULL
, 1);
28 check_popcnt(0xff427e3800556bcdULL
, 0x0802060300040505ULL
, 1);