Use a shorter insruction on x86 for loading unsigned 32-bit immediates into 64-bit registers.#487
Merged
xavierleroy merged 1 commit intoAbsInt:masterfrom Apr 5, 2023
Merged
Conversation
…s into 64-bit registers. Writing into a 32-bit register erases the upper 32 bits of a 64-bit register. This is the shortest instruction for loading unsigned 32-bit immediates. The length of those instructions is: - movl: 5 bytes - movq: 7 bytes - movabsq: 10 bytes Note: Most assemblers will choose the proper instruction by themselves; this commit just makes this explicit.
Contributor
|
For the record, this issue showed up when improving the code generation for division by a constant. The algorithm loads a 64-bit immediate between 2^31 and 2^32-1, which was thus emitted as |
Contributor
|
Well spotted! I was not aware that |
xavierleroy
approved these changes
Apr 5, 2023
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.
Writing into a 32-bit register erases the upper 32 bits of a 64-bit register. This is the shortest instruction for loading unsigned 32-bit immediates. The length of those instructions is:
Note: Most assemblers will choose the proper instruction by themselves; this commit just makes this explicit.