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

Compute "round down to next multiple of alignment" more efficiently #390

Closed
joshlf opened this issue Sep 18, 2023 · 0 comments · Fixed by #393
Closed

Compute "round down to next multiple of alignment" more efficiently #390

joshlf opened this issue Sep 18, 2023 · 0 comments · Fixed by #393

Comments

@joshlf
Copy link
Member

joshlf commented Sep 18, 2023

fn round_down_to_next_multiple_of_alignment(n: usize, align: NonZeroUsize) -> usize {
    let mask = !(align.get() - 1);
    n & mask
}
joshlf added a commit that referenced this issue Sep 18, 2023
This function implements the operation more efficiently using bitmasking
instead of division and multiplication. While LLVM is probably smart
enough in practice to produce this sort of code, Kani (#378) has trouble
with multiplication, and so this code is hopefully more Kani-friendly.

Closes #390
joshlf added a commit that referenced this issue Sep 19, 2023
This function implements the operation more efficiently using bitmasking
instead of division and multiplication. While LLVM is probably smart
enough in practice to produce this sort of code, Kani (#378) has trouble
with multiplication, and so this code is hopefully more Kani-friendly.

Closes #390
joshlf added a commit that referenced this issue Sep 19, 2023
This function implements the operation more efficiently using bitmasking
instead of division and multiplication. While LLVM is probably smart
enough in practice to produce this sort of code, Kani (#378) has trouble
with multiplication, and so this code is hopefully more Kani-friendly.

Closes #390
joshlf added a commit that referenced this issue Sep 19, 2023
This function implements the operation more efficiently using bitmasking
instead of division and multiplication. While LLVM is probably smart
enough in practice to produce this sort of code, Kani (#378) has trouble
with multiplication, and so this code is hopefully more Kani-friendly.

Closes #390
joshlf added a commit that referenced this issue Sep 19, 2023
This function implements the operation more efficiently using bitmasking
instead of division and multiplication. While LLVM is probably smart
enough in practice to produce this sort of code, Kani (#378) has trouble
with multiplication, and so this code is hopefully more Kani-friendly.

Closes #390
@joshlf joshlf mentioned this issue Sep 28, 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 a pull request may close this issue.

1 participant