-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Jit] Skip test
instruction after add
?
#32389
Comments
@benaadams do you have a repro? I see this getting optimized in [MethodImpl(MethodImplOptions.NoInlining)]
static int Foo(long x)
{
long lengthToExamine = x - Vector256<byte>.Count;
if (lengthToExamine != 0)
{
return 1;
}
else
{
return 0;
}
} as 4883C1E0 add rcx, -32
7406 je SHORT G_M34204_IG05 |
gist outputs for G_M14281_IG09:
cmp r8, 32
jl SHORT G_M14281_IG12
xor r9, r9
add r8, -32
test r8, r8
je SHORT G_M14281_IG11 and G_M14281_IG12:
cmp r8, 16
jl SHORT G_M14281_IG15
xor r9, r9
add r8, -16
test r8, r8
je SHORT G_M14281_IG14 |
Ah, in your case we have split trees, so
If I add a second use in my simple example we produce 488D41E0 lea rax, [rcx-32]
4885C0 test rax, rax
7401 je SHORT G_M42597_IG04 which would be even harder to clean up later on. |
Seems like another case for forward substitution -- seems like the tracking issue for this is #4655. |
Have looked into implementing forward sub and am not yet happy with any of the approaches. So am going to mark this as future. |
@AndyAyersMS is the instruction stream still mutable post emit? e.g. |
Perhaps? We are streaming other things along with emission, in particular gc liveness tracking, so "undoing" a previously emitted instruction may not be so easy. |
cc @kunalspathak as this just came up after a presentation Kunal gave that included the new arm64 peepholes... |
@benaadams - We don't have the infrastructure yet to undo the already emitted instruction. @BruceForstall and I discussed some ideas on possibility to do that. But currently, only thing we can do is to avoid emitting current instruction by looking at previous instruction. E.g. #38586 and #38179 |
@kunalspathak perhaps worth looking this one over again, given #53214? |
Thank you @AndyAyersMS for reminding me. I verified and we do eliminate the G_M14186_IG08: ;; offset=008DH
00007ffa`02de8aed 483BCA cmp rcx, rdx
00007ffa`02de8af0 0F84F9000000 je G_M14186_IG17
00007ffa`02de8af6 4983F820 cmp r8, 32
00007ffa`02de8afa 7C60 jl SHORT G_M14186_IG11
00007ffa`02de8afc 33C0 xor eax, eax
00007ffa`02de8afe 4983C0E0 add r8, -32
00007ffa`02de8b02 7434 je SHORT G_M14186_IG10
00007ffa`02de8b04 align [0 bytes] G_M14186_IG11: ;; offset=00F6H
00007ffa`02de8b56 4983F810 cmp r8, 16
00007ffa`02de8b5a 7C5F jl SHORT G_M14186_IG14
00007ffa`02de8b5c 33C0 xor eax, eax
00007ffa`02de8b5e 4983C0F0 add r8, -16
00007ffa`02de8b62 7433 je SHORT G_M14186_IG13
00007ffa`02de8b64 align [0 bytes] |
The following C#
Produces asm:
However
add
sets flags so could this be?category:cq
theme:optimization
skill-level:expert
cost:medium
The text was updated successfully, but these errors were encountered: