-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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: invoke nullable box optimizations earlier #32269
Conversation
Move the logic in `fgMorphRecognizeBoxNullable` into `gtFoldExprSpecial` so it can be invoked earlier. This may prevent the original struct from becoming address exposed and allow subsequent optimizations when the `hasValue` field has a known value. Fixes dotnet#31661.
cc @dotnet/jit-contrib Normal PMI diffs only show a few hits:
however if I modify PMI to use
|
;; Example from 31661
;; before
G_M35686_IG01:
push rax
xor rax, rax
mov qword ptr [rsp], rax
G_M35686_IG02:
xor eax, eax
mov qword ptr [rsp], rax
cmp byte ptr [rsp], 0
jne SHORT G_M35686_IG05
G_M35686_IG03:
mov eax, 1
G_M35686_IG04:
add rsp, 8
ret
G_M35686_IG05:
mov eax, 2
G_M35686_IG06:
add rsp, 8
ret
;; after
G_M35686_IG01:
G_M35686_IG02:
mov eax, 1
G_M35686_IG03:
ret |
Perhaps |
FWIW some of these live builds do strange things -- though I suppose things that should work -- like crossgenning a debug mono SPC. |
@dotnet/jit-contrib PTAL |
|
||
if (val != 0) | ||
{ | ||
return tree; |
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.
We should check for this precondition first, before checking for op->IsCall()
{ | ||
assert(tree->OperKind() & GTK_BINOP); | ||
genTreeOps const oper = tree->OperGet(); | ||
|
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.
This method should either assert or check that oper is GT_EQ, GT_NE or GT_GT rather than implicitly relying on the caller to do this check.
Move the logic in
fgMorphRecognizeBoxNullable
intogtFoldExprSpecial
so it can be invoked earlier. This may prevent the original struct
from becoming address exposed and allow subsequent optimizations when the
hasValue
field has a known value.Fixes #31661.