-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Remove some unneeded code from division morphing #53464
Remove some unneeded code from division morphing #53464
Conversation
It is not necessary: GTF_UNSIGNED does not have anything to do with the operands being unsigned. Some positive diffs in runtime tests for win-x86 and one regression in System.Net.WebSockets.ManagedWebSocket.ApplyMask. The regressions is because we generate two "div"s for a long UMOD on x86 with a constant divisor, always, even for powers of two. Something to improve for sure. Naturally, no diffs for win-x64, linux-x64 or linux-arm.
It used to be that "ldc.i4.1 conv.i8" sequences survived importation, and since UMOD morphing is sensitive to constant divisors, morph tried to fold them. This is no longer the case, so stop doing that. Of course, morph can be called from anywhere at any point, but if some code is creating casts from constants, the proper place to fix is that code. No diffs for win-x86 or win-x64 or linux-arm.
Use modern helpers and move comments around.
PTAL @dotnet/jit-contrib |
@kunalspathak PTAL. |
I am not too familiar with this code, so could you please provide a context on why the sequence |
We fold it: runtime/src/coreclr/jit/importer.cpp Lines 13543 to 13547 in 8103a7e
|
From the runtime/src/coreclr/jit/gentree.h Lines 403 to 404 in 8103a7e
|
Do you have an issue open for the correctness problem? |
I fixed it in #53566. |
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.
Minor comments/questions.
Sure. The code in question is checking the "signedness" of (In general though, I would say that the concept of "signedness" does not apply in IR - all nodes have no sign, they just produce bits. |
Remove GTF_UNSIGNED check from the condition
It is not necessary: GTF_UNSIGNED does not have anything
to do with the operands being unsigned.
Some positive diffs in runtime tests for win-x86 and
one regression in System.Net.WebSockets.ManagedWebSocket.ApplyMask.
The regression is because we generate two "div"s for a long UMOD
on x86 with a constant divisor, always, even for powers of two.
Something to improve for sure (and I have a fix for it in the pipeline).
The diffs
Naturally, no diffs for win-x64, linux-x64 or linux-arm.
Don't fold casts from constants in UMOD morphing
It used to be that
ldc.i4.1 conv.i8
sequences survivedimportation, and since division morphing is sensitive to
constant divisors, morph tried to fold them. This is
no longer the case, so stop doing that.
Of couse, morph can be called from anywhere at any
point, but if some code is creating casts from constants,
the proper place to fix is that code.
No diffs for win-x86 or win-x64 or linux-arm.
There is one more place in morph (
GTF_MUL_64RSLT
recognition) that needs fixing for the same reasons as above, but that one actually has CQ (I regressed it with #47133) and correctness (it can lead to silent bad codegen) implications, so it will be a separate PR.cc @sandreenko