-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functions for reversing the bit pattern in an integer #32798
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Thanks for the PR! Could you elaborate on the motivation for this a bit as well? Looking at the assembly of LLVM for x86_64 it doesn't seem to be doing much special beyond what one could write in Rust anyway? |
On ARM, there are dedicated instructions for reversing bits. The intrinsic would lower to a single |
It seems this intrinsic is only supported on LLVM 3.8+. Since Rust currently supports LLVM 3.6+, should I add a software fallback implementation for older LLVM versions? |
Is there motivation beyond just exporting this because we probably should? Adding a fallback is probably pretty complicated and perhaps not worth it at this time, so it may be best to just wait until we bump the required LLVM version if it's just a nice-to-have. |
I just thought it would be nice to expose these intrinsics to Rust, I don't have a particularly urgent reason to use them myself. |
Ah ok, in that case I'm going to close this for now as we're still trying to remain compatible with LLVM 3.6. If you'd like to draft up a PR to support this even on 3.6 (with a fallback), feel free to send a PR though! |
Add functions for reversing the bit pattern in an integer I'm reviving PR rust-lang#32798 now that the LLVM issues have been resolved. > This adds the bitreverse intrinsic and adds a reverse_bits function to all integer types.
This adds the
bitreverse
intrinsic and adds areverse_bits
function to all integer types.