Skip to content

More efficient is_zero check #718

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

Merged
merged 1 commit into from
Apr 20, 2025
Merged

Conversation

ivanrg99
Copy link
Contributor

rustc is not smart enough to only use or for the generated assembly and adds extra instructions for jumps and compares, to facilitate the short-circuiting check. With a simple bit comparison we achieve the same effect and the compiler
does not generate any branching instructions:

https://godbolt.org/z/6nrhvsxs7

@Tony-Samuels
Copy link
Collaborator

Looks like we'll need a clean-up MR first to fix some issues not introduced by this change.

@paupino
Copy link
Owner

paupino commented Mar 25, 2025

Nice find!

I think this should target the v1 branch as opposed to master. It seems like a stable fix, which can also be applied to the currently unstable master. (I.e, merge/release against v1, then v1 propagates up to master).

@ivanrg99
Copy link
Contributor Author

I think this should target the v1 branch as opposed to master. It seems like a stable fix, which can also be applied to the currently unstable master. (I.e, merge/release against v1, then v1 propagates up to master).

Should I create a new PR then with v1 as the base that targets v1 and close this one?

@paupino paupino changed the base branch from master to v1 March 25, 2025 13:31
@Tony-Samuels
Copy link
Collaborator

Tony-Samuels commented Mar 25, 2025

Should I create a new PR then with v1 as the base that targets v1 and close this one?

I think we'd like this on both. If you leave this one open and create a new one for v1, then I'll make sure this one is merged when we sort out master.

@paupino
Copy link
Owner

paupino commented Mar 25, 2025

Oh, yeah - it looks like you may need to rebase your change onto v1 first.

Sorry, I've started using master for unstable breaking change cleanups (aka v2). I need to make sure it's clear for any new contributors what to do here - maybe a pull request template could help?

@Tony-Samuels Tony-Samuels changed the base branch from v1 to master March 25, 2025 13:41
@ivanrg99
Copy link
Contributor Author

Created #719 using v1 and targeting v1

@Tony-Samuels Tony-Samuels merged commit aaebb9f into paupino:master Apr 20, 2025
22 of 30 checks passed
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.

3 participants