Repository navigation
x86: keep all bits in bextr when the length covers the operand - #2453
Open
bacescuandrei wants to merge 1 commit into
Open
bacescuandrei wants to merge 1 commit into
bacescuandrei wants to merge 1 commit into
Conversation
bextr clamped LEN to 63 (or 31) and built the mask as (1 << LEN) - 1, so a length at or above the operand size dropped the top bit: bextr rax, rbx, rcx with rbx = 0x8000000000000000 and rcx = 0x4000 gave 0. Build an inverse mask that is cleared for lengths above the bound, as QEMU gen_BEXTR does.
This branch has not been deployed
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.
bextrclamps LEN to the operand-size bound (63 or 31) and builds the mask as(1 << LEN) - 1, so a length at or above the operand size drops the top bit of the result:The Intel SDM defines the result as the
LENbits starting atSTART, with all remaining bits of the operand kept whenLENreaches past it. This change builds an inverse mask-1 << LENthat is cleared for lengths above the bound, which is how QEMU's currentgen_BEXTR(target/i386/tcg/emit.c.inc) does it. Lengths below the operand size are unchanged.Test:
test_x86_bextr_lenintests/unit/test_x86.ccovers lengths 64 and 255, length 63, start 63 with length 1, and the 32-bit form with length 32. Without the change the length-64, length-255 and 32-bit cases fail; with it the test and the rest oftest_x86pass (x86-only Debug build, Linux x86_64).