-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: Avoid internal register allocation when possible for PUTARG_SPLIT #76443
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: Avoid internal register allocation when possible for PUTARG_SPLIT #76443
Conversation
We can almost always avoid allocating an internal register, which may be expensive if lr is picked since we cannot use thumb encoding for it. The only case where we need an internal register is when we have a source that is in a register, and we have a single taget register to place that conflicts with that source register. The to-stack copies then need an intermediate scratch register to avoid clobbering the source register.
|
Should fix regression seen in #76017 (comment). |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsWe can almost always avoid allocating an internal register, which may be expensive if lr is picked since we cannot use thumb encoding for it. The only case where we need an internal register is when we have a source that is in a register, and we have a single taget register to place that conflicts with that source register. The to-stack copies then need an intermediate scratch register to avoid clobbering the source register.
|
cc @dotnet/jit-contrib PTAL @BruceForstall |
| } | ||
| } | ||
|
|
||
| // Find first register to place. If we are placing addrReg, then |
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.
Just that I understand, we basically pick the first register to place after addrReg and round robin back so addrReg is placed last?
For r0, r1, addrReg, r3, r4, we will place: r3, r4, r0, r1, addrReg?
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.
If yes, can you call that out in comment with an example. Initially it was not clear to me, if that's what we meant.
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.
Exactly. I'll add a comment like you suggested.
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.
Done, PTAL
| { | ||
| if (treeNode->GetRegNumByIdx(i) == addrReg) | ||
| { | ||
| firstRegToPlace = i + 1; |
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.
| firstRegToPlace = i + 1; | |
| firstRegToPlace = (i + 1) % treeNode->gtNumRegs; |
That way, you can remove the code from below loop:
if (curRegIndex == treeNode->gtNumRegs)
{
curRegIndex = 0;
structOffset = 0;
}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.
It still needs to be handled in below loop (since the loop there also increments curRegIndex). So I think I'll leave it as is.
BruceForstall
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
We can almost always avoid allocating an internal register, which may be expensive if lr is picked since we cannot use thumb encoding for it.
The only case where we need an internal register is when we have a source that is in a register, and we have a single taget register to place that conflicts with that source register. The to-stack copies then need an intermediate scratch register to avoid clobbering the source register.