Lol -- "Like cttz, but extra-unsafe (...)" https://doc.rust-lang.org/std/intrinsics/fn.cttz_nonzero.html …
-
Show this thread
-
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".
1 reply 0 retweets 0 likesShow this thread -
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
3 replies 0 retweets 1 likeShow this thread -
Replying to @yoshuawuyts @sadisticsystems
with ` -C target-cpu=native` it'll use the tzcnt instruction (on whatever machine godbolt runs at least)
1 reply 0 retweets 2 likes -
Replying to @killercup @sadisticsystems
Woahhhh! Had no idea that was a thing; makes a lot of sense tho!pic.twitter.com/bhhFtXXqAv
2 replies 0 retweets 0 likes
Woah; it seems there's precedence for a similar change already! The difference for `.count_zeros()`, and `.count_ones()` is an extra `not` instruction. Just like it'd be if a `.trailing_ones()` method would be added!* https://godbolt.org/z/ArBv8P pic.twitter.com/Y16FdiGncC
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.