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

feat: convert x.sdiv (2^k) into x.sshiftRight k #35

Closed
wants to merge 6 commits into from
Closed

Conversation

bollu
Copy link

@bollu bollu commented Nov 12, 2024

Subtleties abound, mostly to do with intMin, and when 2^k is a sensible number, when it is intMin, and when it overflows.

@bollu bollu changed the base branch from master to bitvec_toInt November 12, 2024 18:56
@bollu bollu changed the base branch from bitvec_toInt to master November 12, 2024 18:56
@bollu
Copy link
Author

bollu commented Nov 13, 2024

image

The relevant section from Hacker's delight: 10-1

@bollu
Copy link
Author

bollu commented Nov 18, 2024

This is pointless, because sdiv is already unfolded into udiv, which knows how to handle power-of-two. That encoding is competitive with this encoding. The only thing that could make this faster is to use a branchless encoding, but there's higher priority stuff right now, so I won't pursue this. Closing.

@bollu bollu closed this Nov 18, 2024
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