-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do some minor enhancements of the code generation in the JIT #7956
Merged
Conversation
This file contains 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
CT Test Results 3 files 140 suites 46m 38s ⏱️ Results for commit 1e3099e. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
4f5e2d9
to
2123d6f
Compare
jhogberg
reviewed
Dec 19, 2023
jhogberg
reviewed
Dec 19, 2023
jhogberg
reviewed
Dec 19, 2023
Leverage the bitfield manipulation instructions to optimize matching. Consider this example: bm(<<X:16, Y:16, Z:16>>) -> {X, Y, Z}. In OTP 26, the code for extracting the `X`, `Y`, and `Z` variables looks like this: # extract integer 16 ror x7, x7, 48 mov x27, 15 bfi x27, x7, 4, 16 # extract integer 16 ror x7, x7, 48 mov x28, 15 bfi x28, x7, 4, 16 # extract integer 16 ror x7, x7, 48 mov x15, 15 bfi x15, x7, 4, 16 With this commit, the code is simplified to: # extract integer 16 mov x4, 15 orr x27, x4, x7, 44 # extract integer 16 ubfx x9, x7, 32, 16 orr x28, x4, x9, 4 # extract integer 16 ubfx x9, x7, 16, 16 orr x15, x4, x9, 4
Consider this example: bb(<<X:8, Y:8, Z:8>>) -> <<X:16, Y:16, Z:16>>. In OTP 26, the code for constructing the binary from the values of `X`, `Y`, and `Z` looks like this: # accumulate value for integer segment bfxil x7, x27, 4, 16 # accumulate value for integer segment lsl x7, x7, 16 bfxil x7, x28, 4, 16 # accumulate value for integer segment lsl x7, x7, 16 bfxil x7, x15, 4, 16 # construct integer segment from accumulator rev64 x7, x7 lsr x7, x7, 16 With this commit, the code is simplifed to: # accumulate value for integer segment at offset 48 bfi x7, x27, 44, 20 # accumulate value for integer segment at offset 32 bfi x7, x28, 28, 20 # accumulate value for integer segment at offset 16 bfi x7, x15, 12, 20 # construct integer segment from accumulator rev64 x7, x7
Simplify the code when right-hand side operand is constant. Also eliminate some register shuffling by using the LEA instruction.
Take better advantage of operand types. * If one operand is known to never be an immediate term, don't emit any test for immediate operands. (Just go ahead and call the helper fragment.) * Don't do any immediate test for known immediates.
* Inline equality test with lists of a single immediate element (such as `[42]` or `[a]`). Call a specialized helper fragment for equality test with lists of two or more immediates. * Call a a specialized helper fragment for matching tuples containing only immediates. Use the same helper fragment for matching bignums and floats. * Inline comparisons with empty binaries and empty maps.
7df94e3
to
1e3099e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
team:VM
Assigned to OTP team VM
testing
currently being tested, tag is used by OTP internal CI
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.
Take better advantage of type information and known constant operands to enhance code generation. Also take advantage of the bit manipulation instructions for AArch64 to enhance code generation for the binary syntax.