logoalt Hacker News

camel-cdryesterday at 9:29 PM3 repliesview on HN

nth_set_bit_u64: wouldn't that be __builtin_ctzll(_pdep_u64(1<<n, v)) with BMI2?


Replies

kwilletstoday at 12:48 AM

That's my guess as well.

Bitstring rank/select is a well-known problem, and the BMI and non-BMI (Hacker's Delight) versions are available as a reference.

stousettoday at 2:46 AM

I believe the equivalent ARM64 instructions are in SVE2 which isn’t yet supported on Apple’s M-series chips as of M4, sadly.

SkiFire13yesterday at 10:21 PM

That's assuming you're ok with your program not running on some older cpus.

show 1 reply