-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix STOREIND optimization. #39066
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
Fix STOREIND optimization. #39066
Conversation
|
PTAL @AndyAyersMS @BruceForstall. I have constructed a repro for the issue that we have discussed earlier. I added a fix but have not tested it fully, so probably we will see ci failures due to new asserts in lowering, but I believe my fix in cc @dotnet/jit-contrib |
|
What would be the impact of the simple fix where we just disable |
|
A somewhat related question: should |
|
Here's a C# repro case based on the WPF code: This currently prints The bad codegen is in |
|
what was the impact of this issue on the WPF case, was it that the double values expected by SetWindowPos incorrect? When Aaron and I were investigating it appeared that the right size values were present, unless they were somehow misaligned. |
|
I think it's that WPF handles |
we had a copy of 8 bytes from a source to a destination, and the first field in the source was ubyte, so instead of copying 8 bytes from source address the Jit was taking this field, sign extended it and copied that value to the dst. So we were losing 7 bytes of data. |
|
Right, the 8 byte copies were the various This struct describes the window size, so as a result the window size was messed up. |
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. Thanks for adding the tests.
Consider triggering jitstress job.
AndyAyersMS
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.
Looks good.
Can you open a follow-up issue for the more general fix?
I wonder if we should do some extra testing on WPF for this. I will look into it.
Triggered, will wait for it to finish before merging this.
Sure, was planning to do so. |
|
/cc @jkoritzinsky |
|
@sandreenko the newly added IL test is failing with asserts / invalid IL. |
Will drop the test and keep your test for this PR, interesting that we have 3 results for the IL test: 64bit platforms: passing, 32bit platforms: morph assert, mono: invalid IL. |
dotnet/wpf#3226 exposed a scenario when optimization from #38316 did not work correctly.
That PR adds a repro case for that behavior (the scenario requires very specific conditions to expose the problem) and a fix.
In short we need to get a tree like:
where
FIELD bytesurviveslclMorphandglobalMorph, in order to do that the dest struct has to be non-promotable (in my repro >4 fields) andFIELDhas to be in the form of(otherwise, lclMorph optimizes it to a
LCL_FLD byteand thenfgMorphBlockOperandcreates a correctIND struct(ADDR(LCL_FLD byte))on top of it.if these conditions were met we could have had an IR like (after global morph):
that was transformed into:
and then the added optimization was transforming it into:
without the added optimization we also ended with a wrong
IND byte, but we always markSTORE_OBJsrc as contained, so we did not put it in a register andSTORE_OBJwas reading the number of bytes written inDST, not inSRC.Note: I did not have a chance to shrink the repro and fix names etc, will do tomorrow.