Repository navigation
x86: model shift-count masking; opt-in masked-shift selection (#11, approved trusted-base change) - #32
Merged
Conversation
Trusted-base change approved in issue #11: the variable-count shifts Psall_rcl, Pshrl_rcl and Psarl_rcl now mask the count to 5 bits, and Psalq_rcl, Pshrq_rcl and Psarq_rcl to 6 bits, as the hardware does (Intel SDM, SAL/SAR/SHL/SHR). This refines the previous semantics, which were undefined for larger counts and agree elsewhere. New operators Oshlmask/Oshrmask/Oshrumask and their 64-bit variants have the masked semantics. With -fshift-mask (off by default), selection compiles x << (y & 31) and the like, including the low word of a 64-bit y & 31, to them, and Asmgen emits the plain %cl shift without the and. The plain shift operators use the refined instructions through a lemma that the masked result is at least as defined as the unmasked one. Without -fshift-mask the generated code is unchanged. nsievebits: -6.3% with the flag.
…PORT.md section 17) Closes #11.
16 of 17 tasks
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.
Closes #11. Trusted-base change, approved by the owner, who applied
approved: trusted-baseon #11 and confirmed in chat.Trusted part: exactly the approved text
The six
*_rclcases inx86/Asm.vnow mask the shift count: 31 forsall/shrl/sarl, 63 for the q forms. I checked the diff line by line against the proposal posted on #11. Nothing else in trusted files changed except the flag line inextraction/extraction.v. No printer change.Validation:
asm_difftestgroupshiftagainst the extracted new semantics: all counts 0..255 with garbage in the upper bits of%rcx, about 20k tests per instruction, 0 mismatches, 100% defined (previously 6–13% defined).Verified part
Oshlmask/Oshrmask/Oshrumaskand their 64-bit variants, with masked semantics.-fshift-mask(off by default) forx << (y & 31)etc., including the low word of a 64-bity & 31.%clshift.shift_mask_lessdef).Results
-fshift-mask: only nsievebits changes. It is −6.3% (interleaved timing, 94.1 → 88.2 ms).Protocol checklist (#1)
x86/Asm.v(approved text), plus the flag line inextraction/extraction.v.check_axioms.sh: adds onlyCompopts.optim_shiftmask.make proof: x86_64 (clean rebuild), x86_32, aarch64, arm, powerpc, rv64.make -C test all test: 154 passed, both by default and withCCOMPOPTS=-fshift-mask.faster-compcert/TRUSTED_BASE.md.