-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: handle some side effects in box pattern match #1741
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: handle some side effects in box pattern match #1741
Conversation
Handle simple side effects in the `box; br` pattern based optimization. Fixes dotnet#1713.
|
cc @dotnet/jit-contrib @jkotas Seems like an important enough case to warrant handling in the jit, despite the small number of impacted methods. Does not hit outside of SPC. TIER0 TIER1 Tried a couple of experiments to mitigate the size regressions, but no luck. They are small. |
|
What do the size regressions look like? |
CarolEidt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Here is a typical diff, from ;;; before
;;; r11 is a span's pointer field, ecx is the span length, r15 the index
G_M45276_IG05:
lea r14d, [rax+rbp]
lea r15d, [r14-1]
cmp r15d, ecx
jae G_M45276_IG13
movsxd r15, r15d
mov r15, qword ptr [r11+8*r15]
cmp r14d, ecx
jae G_M45276_IG13
movsxd r14, r14d
mov r14, qword ptr [r11+8*r14]
cmp r15, r14
jl SHORT G_M45276_IG08
;; bbWeight=2 PerfScore 18.50
G_M45276_IG06:
cmp r15, r14
jle SHORT G_M45276_IG09
;;; after
G_M45276_IG05:
lea r14d, [rax+rbp]
lea r15d, [r14-1]
cmp r15d, ecx
jae G_M45276_IG13
movsxd r15, r15d
lea r15, bword ptr [r11+8*r15]
cmp dword ptr [r15], r15d // residual null check
cmp r14d, ecx
jae G_M45276_IG13
movsxd r14, r14d
mov r14, qword ptr [r11+8*r14]
cmp qword ptr [r15], r14
jl SHORT G_M45276_IG08
;; bbWeight=2 PerfScore 23.00
G_M45276_IG06:
cmp qword ptr [r15], r14
jle SHORT G_M45276_IG09Without this change, at Tier1, the So sometimes there's a benefit to a GT_IND based nullcheck, sometimes there's a benefit to GT_NULLCHECK; we can't tell locally which might end up working out better, and we can't normalize to whichever form is better downstream. |
Handle simple side effects in the
box; brpattern based optimization.Fixes #1713.