-
Notifications
You must be signed in to change notification settings - Fork 396
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
Provide implementation for fast integral log2 #5277
Comments
A bigger issue is to contribute such utility functions to a more common OMR component (e.g., in |
Hi @0xdaryl ! Let me know if you have comments. If you are okay with this, I would love to take this up ! I am just starting off contributing to open source and this should be a good beginners exercise. |
@0xdaryl in case you missed my earlier comment :) |
Thanks for the poke. My apologies, I did miss your update earlier. First off, thanks for your offer to help. New contributors are always welcome! One of the big advantages of implementing N-bit Some of our build compilers provide intrinsics for the CLZ family of instructions. For those that don't I believe inline assembly should suffice. In thinking the design of this through a bit more, I realize to be truly efficient we should really be replacing the Perhaps this work can be split into two parts: the first is implementing a [1] x86 ( |
Integral log2 (essentially a floor base-2 logarithm function on integral types) is useful in some contexts during compilation. Provide a fast implementation that lives in
infra/Bit.hpp
. I suggest an implementation based on the Hacker's Delight definition of integrallog2
, which essentially defineslog2(0) = -1
(which isn't true in the mathematical sense) and makes the computation more efficient.For example, the implementation for 32-bit
log2
is simply:This results in:
leadingZeroes
has been optimized in the compiler depending on the architecture.Provide a version for 64-bit integrals as well. Create test cases to exercise these functions.
The text was updated successfully, but these errors were encountered: