Skip to content
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

Replace BitHacks.Log2 with implementation based on de Bruijn sequence #408

Merged
merged 2 commits into from
May 26, 2023

Conversation

aloraman
Copy link
Contributor

Replace implementation of BitHacks.Log2Floor and BitHacks.Log2Ceil with more bit-hacky de Bruijn multiplication.

  • smaller precomputed tables
  • less instruction branching
  • some test coverage

Further optimizations are possible:

@ulex ulex self-requested a review May 25, 2023 13:20
rd-net/Lifetimes/Util/BitHacks.cs Outdated Show resolved Hide resolved
rd-net/Lifetimes/Util/BitHacks.cs Outdated Show resolved Hide resolved
@ForNeVeR ForNeVeR requested a review from ulex May 26, 2023 10:59
Copy link
Collaborator

@ulex ulex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so for your contribution and suggestions, @aloraman !
At the moment I see no way to use either ReadOnlySpan or runtime intrinsics: one of our targets is net35.
The proposed implementation is excellent for its purpose.
PS Thank you for giving me an opportunity to learn about De Bruijn multiplication

@ulex ulex merged commit 24b5ca6 into JetBrains:master May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants