Handle remainder as a wide word in div3by2#647
Merged
tarcieri merged 1 commit intoRustCrypto:masterfrom Aug 15, 2024
Merged
Conversation
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
tarcieri
approved these changes
Aug 15, 2024
fjarri
reviewed
Aug 16, 2024
| // If r < b and q*y[-2] > r*x[-1], then set q = q - 1 and r = r + v1 | ||
| let done = ConstChoice::from_word_nonzero((rem >> Word::BITS) as Word) | ||
| .or(ConstChoice::from_wide_word_le(qy, rx)); | ||
| quo = done.select_word(quo.saturating_sub(1), quo); |
Contributor
There was a problem hiding this comment.
I would rather have wrapping_sub here, I'm not sure if saturating_sub is constant-time
Member
There was a problem hiding this comment.
Spot checking it in Godbolt saturating_sub uses cmovae on x86 and csel on aarch64, which (for now, until the optimizer decides differently) seem pretty ideal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In regards comments on #646, this handles potential overflow in the remainder value.