-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Check that we don't create null checks on an address that is not null. #44059
Check that we don't create null checks on an address that is not null. #44059
Conversation
@@ -1301,6 +1301,7 @@ inline GenTree* Compiler::gtNewIndir(var_types typ, GenTree* addr) | |||
|
|||
inline GenTree* Compiler::gtNewNullCheck(GenTree* addr, BasicBlock* basicBlock) | |||
{ | |||
assert(fgAddrCouldBeNull(addr)); |
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 is questionable if it should be an assert or
if (!fgAddrCouldBeNull(addr))
{
// No need for a null-check.
return addr;
}
or something else.
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'd be weird for gtNewNullCheck
to return something other than null-check 🙂
PTAL @AndyAyersMS @dotnet/jit-contrib |
@sandreenko, would it also fix #1368, since runtime/src/coreclr/src/jit/flowgraph.cpp Lines 7327 to 7330 in 3d20030
|
yeah that one is already fixed |
@sandreenko Since you touch it, could you please address #37245 (comment) as part of this PR? 🙂 |
Sure, done |
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.
I wonder if we can do something similar over in gtTryRemoveBoxUpstreamEffects
-- it currently create an implicit null check, and does not check for the same "can optimize away the check" cases that the importer pattern match does.
@erozenfeld may have already tried this.
I pushed a change with the same check for |
9e13842
to
72ee330
Compare
Actually, I remember that I was trying to do that in the past and it did not work. |
Seems like a good idea. Would be good to note more details on why it's not as simple as it might seem. |
@EgorBo in his previous Pr gave me an idea that it could be useful to check that we don't create a null check on an address that is known to be not null.
The biggest number of diffs involves methods on arm64 windows:
they all are in
IndexOf
orLastindexOf
and are due to a new loop hoisting that is a size regression but a performance improvement.