Skip to content
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

[mono][jit] Partially implemented logical immediates on arm64 #93606

Merged
merged 5 commits into from
Oct 19, 2023

Conversation

jandupej
Copy link
Member

@jandupej jandupej commented Oct 17, 2023

This implements a subset of https://developer.arm.com/documentation/ddi0596/2020-12/Base-Instructions/AND--immediate---Bitwise-AND--immediate-- (incl. ands, eor, orr). If the immediate value can be expressed as (1<<n) - 1, the new codegen is used. Although this covers only a few of the cases supported by the instruction, the instances where we are trying to mask away some of the upper bits seem prevalent (in our codebase) and are handled here.

E.g. clamping the shift amount in long shifts:

0000000000000018        mov     x30, #0x3f
000000000000001c        and     w1, w0, w30

becomes

0000000000000018        and     w1, w0, #0x3f

EDIT: The recognized bit pattern is now expanded to 0*1+0*. A plain-ish HelloWorld build revealed almost 400 instances of this pattern.

Copy link
Member

@lambdageek lambdageek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctz is for 32-bit inputs

src/mono/mono/mini/mini-arm64.c Outdated Show resolved Hide resolved
src/mono/mono/mini/mini-arm64.c Outdated Show resolved Hide resolved
@@ -620,62 +625,131 @@ emit_subx_sp_imm (guint8 *code, int imm)
return code;
}


static int
num_trailing_zeros (guint64 imm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put this in a header in mono/utils (or in minipal) so we can use it in more places

@jandupej jandupej requested a review from matouskozak October 18, 2023 10:43
@jandupej
Copy link
Member Author

CI failures are not related. Merging.

@jandupej jandupej merged commit 7a5f0c2 into dotnet:main Oct 19, 2023
@jandupej jandupej deleted the arm64-logical-imm branch October 19, 2023 12:48
@ghost ghost locked as resolved and limited conversation to collaborators Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants