Lol -- "Like cttz, but extra-unsafe (...)" https://doc.rust-lang.org/std/intrinsics/fn.cttz_nonzero.html …
Anyway, found the definition of "<integer>.trailing_zeros()" in the source https://github.com/rust-lang/rust/blob/8ec22e7ec7ed0da2add0763d239e77c5474f3d4a/src/libcore/intrinsics.rs#L1408 … Which in turn is compiled into this LLVM code: https://llvm.org/docs/LangRef.html#llvm-cttz-intrinsic … There doesn't appear to be any "intrinsic" available in either to count "trailing ones".
-
-
This is the fastest I can get this by the way (thanks to
@sadisticsystems for suggestion). I'm don't think there might be a way to speed things up further. Kind of wish `.trailing_ones()` could be a thing. Maybe this would make for a good RFC? https://godbolt.org/z/7g8ZM5 pic.twitter.com/krXHJ06lcK
Show this thread -
Not sure what people would think of adding methods to numbers that don't directly map to LLVM intrinsics. I'm guessing folks might not be into it? Although from a user perspective, it kind of makes sense that if you can count zeros, you can also count ones. API symmetry!
Show this thread
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.