Uh oh!
There was an error while loading. Please reload this page.
ARM64 - Always morph GT_MOD - #68885
Conversation
ghost
commented
May 5, 2022
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsShould resolve these regressions:
Description Currently a draft. We only want to do the specific ARM64 mod optimization if the morphed The idea here is to find the But it gets more complicated. Acceptance Criteria
|
…s constant non-zero value
TIHan
commented
May 6, 2022
@kunalspathak - I think this is handling those regressions we saw earlier with the use of Looking at the asmdiffs now, it does show a lot of regressions, but they are caused by the additional divbyzero and overflow check: G_M60555_IG04: ; gcVars=0000000000000000 {}, gcrefRegs=0000 {}, byrefRegs=0000 {}, gcvars, byref
bl CORINFO_HELP_OVERFLOW
;; size=4 bbWeight=0 PerfScore 0.00
G_M60555_IG05: ; gcrefRegs=0000 {}, byrefRegs=0000 {}, byref
bl CORINFO_HELP_THROWDIVZERO
brk_windows #0
;; size=8 bbWeight=0 PerfScore 0.00These were here before we merged |
jakobbotsch
commented
May 6, 2022
I think recognizing patterns this large in lowering is too fragile and hard to get right. |
jakobbotsch
commented
May 6, 2022
It might also be reasonable to introduce additional transformations as part of rationalization (or separately, with higher TP cost). We also have #68103 where it would be good to have. Thoughts @dotnet/jit-contrib? |
BruceForstall
commented
May 8, 2022
I definitely agree with this. I don't know if there is a better option (why can't it be done in morph?), though. |
I agree as well. Originally, I only wanted to find the This specific optimization shouldn't be done in morph, even if we had the constructs to do so. The reason why is because the transformation of letx= index /16lety= index %16which would turn into: letx= index /16lety= index -(index /16)*16then: letcse= index /16lety= index - cse *16At the moment, we are not taking advantage of CSE because we merged in the What I really want to do is look for |
jakobbotsch
commented
May 13, 2022
I would be interested to see a prototype of the suggestions I had above. I.e. try it as part of rationalization (in pre-order there), and try a new late phase (e.g. after range check). We can see how costly the full IR walk will be and evaluate whether having the optimization and future opportunity to do other things in that pass outweighs that cost. |
Note that we already have an "simple lowering" pass in our phase order that is a (mostly "empty") full IR walk. |
jakobbotsch
commented
May 13, 2022
It's after rationalization however, so folding transformations still require interference checking here (or otherwise coupling it to rationalization). |
SingleAccretion
commented
May 13, 2022
Yep, the idea would be to move it to before rationalization. Tree walks are still costlier than linear traversals, but not "a new full IR walk" costlier at least. |
Uh oh!
There was an error while loading. Please reload this page.
i % 2| case GT_LE: | ||
| case GT_GE: | ||
| case GT_GT: | ||
| case GT_CMP: |
There was a problem hiding this comment.
Needed to add this so that GT_CMP's second operand can be properly contained.
TIHan
commented
Jun 10, 2022
@dotnet/jit-contrib this is ready again, CI is green now |
TIHan
commented
Jun 10, 2022
jakobbotsch
commented
Jun 10, 2022
I'd suggest to split the new optimization into a separate PR so we can review it and track its impact separately. |
Uh oh!
There was an error while loading. Please reload this page.
i % 2TIHan
commented
Jun 10, 2022
@jakobbotsch I split them out |
| use.ReplaceWith(cc); | ||
| return cc->gtNext; | ||
| ContainCheckNode(mod); |
There was a problem hiding this comment.
Are these changes necessary or should they be done in the new PR too?
There was a problem hiding this comment.
Sort of? I got rid of the use. New PR extends this path anyway with the new instruction.
There was a problem hiding this comment.
But this is unrelated to the fix, right?
I am fine with leaving it to avoid more churn on this PR.
There was a problem hiding this comment.
It is unrelated, been trying different ways to shape this function. The next PR is the shape and impl I'm happy with.
Uh oh!
There was an error while loading. Please reload this page.
Should resolve these regressions:
Assertion failed '!"Shouldn't see an integer typed GT_MOD node in ARM64"' during 'Linear scan register alloc' #68470Seems to not reproduce in main anymore.Description
We only want to do the specific ARM64 mod optimization if the morphed
ModtoSubMulDivdid not take advantage of CSE. The only phase, that I know of, to do any kind of transformation that occurs after CSE is 'lowering'.The idea here is to find the
SubMulDivin lowering, turn it back into aMod, and then callLowerModPow2to do the specific optimization.But it gets more complicated.
SubMulDivitself gets optimized in lowering as well, so the shape ofSubMulDivis lost. Therefore, we need to find other possible shapes that get lowered fromSubMulDiv.Acceptance Criteria