Uh oh!
There was an error while loading. Please reload this page.
Creating comma temps differently for SubMulDiv morph - #69770
Conversation
ghost
commented
May 25, 2022
Tagging subscribers to this area: @JulieLeeMSFT Issue DetailsAt the moment, this is an experiment. This changes how comma temps are created for SubMulDiv morph. Example code: (multiplier * seed2 + increment)% Modulus;In morph, this would turn into: (lettmp1= multiplier * seed2 + increment)in tmp1)-(tmp1 / Modulus)* ModulusThis PR morphs it into: lettmp1= multiplier * seed2 + increment in
tmp1 -(tmp1 / Modulus)* Modulus
|
TIHan
commented
May 26, 2022
@dotnet/jit-contrib This is ready. The diffs will show some regressions, but they are not detrimental. The improvements on both x64 and ARM64 look good, especially ARM64. |
TIHan
commented
May 27, 2022
@kunalspathak@AndyAyersMS - I feel good about this change and it's ready. It should help optimizing 'mod' since I'll be able to do the transformation before rationalization. |
1 similar comment
TIHan
commented
May 27, 2022
@kunalspathak@AndyAyersMS - I feel good about this change and it's ready. It should help optimizing 'mod' since I'll be able to do the transformation before rationalization. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
JulieLeeMSFT
commented
May 27, 2022
@TIHan can you show the perf results in this PR? |
TIHan
commented
May 31, 2022
Here is the link to the diffs: Diffs |
kunalspathak
commented
Jun 1, 2022
Seems there is significant regression introduced on arm64: |
kunalspathak
commented
Jun 1, 2022
just noticed your message about the regression in #69770 (comment) |
kunalspathak
commented
Jun 1, 2022
| // eliminate the redundant div from code like "x = a / 3; y = a % 3;". | ||
| // | ||
| // Before: | ||
| // * RETURN int |
There was a problem hiding this comment.
Something doesn't feel right in Before: tree. Did it mean to have (V00 * V00) % V01. Same in After:.
There was a problem hiding this comment.
(V00 * V00) % V01 is intentional.
In the after tree, you see that it takes (V00 * V00) and hoists it out:
// +--* ASG int
// | +--* LCL_VAR int V03 tmp1
// | \--* MUL int
// | +--* LCL_VAR int V00 arg0
// | \--* LCL_VAR int V00 arg0
There was a problem hiding this comment.
As spoke offline, change MUL to BINOP and add a note that it is applicable for any BINOP that is safe to clone.
TIHan
commented
Jun 1, 2022
It does look significant, but when I looked at the top regressions, the actual code is really wild with a lot of casts and checked contexts - something you really would not see in user code. |
TIHan
commented
Jun 1, 2022
That is a good catch. I'm surprised by this one - I'm even more surprised how it was able to CSE it before because one of the ops would have a |
kunalspathak
commented
Jun 1, 2022
My before and after were flipped. I think it looks good. |
TIHan
commented
Jun 1, 2022
As a note from @kunalspathak 's comment regarding the |

Description
This changes how comma temps are created for SubMulDiv morph.
Example code:
In morph, this would turn into:
This PR morphs it into:
Basically, we are moving the comma temps to be the root of the expression instead of leafs.
Acceptance Criteria
Diffs