Test signed right shift on pre-Constantinople EVMs via IR codegen#16755
Open
msooseth wants to merge 1 commit into
Open
Test signed right shift on pre-Constantinople EVMs via IR codegen#16755msooseth wants to merge 1 commit into
msooseth wants to merge 1 commit into
Conversation
YulUtilFunctions::shiftRightSignedFunctionDynamic emits either sar(bits, value) on Constantinople+ or a manual xor/div/xor fallback on earlier EVMs. The fallback path was not directly exercised by any existing semantic test under via-IR: shift_right_garbled_signed_v1.sol is explicitly compileViaYul: false, and bitwise_shifting_constantinople*.sol are >=constantinople. Add a test that pins down signed right shift semantics on <constantinople with compileViaYul: also, covering int8 and int256 boundaries (sign bit set/unset, INT*_MIN, INT*_MAX, shift amounts 0, 1, type bits-1, type bits, and >= 256). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
YulUtilFunctions::shiftRightSignedFunctionDynamichas two arms:sar(bits, value)on Constantinople+, and a manualxor(div(xor(value, mask), divisor), mask)fallback on earlier EVMs.operators/shifts/shift_right_garbled_signed_v1.solis explicitlycompileViaYul: false.operators/shifts/bitwise_shifting_constantinople*.solare>=constantinople.operators/shifts/shift_right_signed_pre_constantinople.solwithEVMVersion: <constantinopleandcompileViaYul: also, covering int8 and int256 boundaries (sign bit set/unset, INT*_MIN, INT*_MAX, shift amounts 0, 1, type-bits-1, type-bits, and ≥ 256).shift_right_garbled_signed_v2.sol) so Solidity's cleanup-on-read does the sign extension — avoiding the ABI v2 decoder rejecting non-sign-extended int8 calldata.No production code changes; this is pure coverage.
Test plan
isoltest --evm-version byzantium -t "semanticTests/operators/shifts/shift_right_signed_pre_constantinople"→ OK (both legacy and via-IR pipelines).