Repository navigation
Conversation
…t behavior rotateLeftInt shifts the value left without masking, so the bits that wrap around also stay above the type's width (e.g. 0x8000_0000_u32 rotated left by 1 was stored as 0x1_0000_0001), and signed types got the unsigned representation. The existing test did not notice because its `r == c` assertion becomes a SwitchInt on `r`, and #switchMatch truncates the discriminant before comparing.
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.
This PR fixes the implementation of the
rotate_leftintrinsic and adds a correspondingrotate_right, along with tests for those operators.Specifically, the two bugs fixed in
rotate_leftare the following:#rotateLeftIntshifts the value left without truncating, so the bits that wrap around also stay above the type's width (e.g.0x8000_0000_u32rotated left by 1 was stored as0x1_0000_0001). The existing test missed this because ther == cassertion was compiled into aSwitchIntonr, and#switchMatchalready inserts a truncation before comparing. However, in other cases, the missing truncation can lead to incorrect behavior. For example, a shift right could incorrectly bring the extra bits back. This was fixed by having#execRotateLefttruncate the result of#rotateLeftInt, and a new test was added covering this case.truncatetakes an argument specifying whether the result should be interpreted as signed or unsigned. However, this required splitting the definition of the rule to handle each case separately.rotate_rightwas then implemented following the correctedrotate_leftimplementation, with corresponding tests added as well.