Remove the "anything + null => null" optimization (#61518)
authorSingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Mon, 15 Nov 2021 16:35:28 +0000 (19:35 +0300)
committerGitHub <noreply@github.com>
Mon, 15 Nov 2021 16:35:28 +0000 (08:35 -0800)
commit3d7e89c1c929b1365423730693d9732391c608ec
treebe827822aded558602b4aa0517fdabddc81c98ba
parent4cf86c2abfe9b2fad5ab2a48e4b0717ff0daf27a
Remove the "anything + null => null" optimization (#61518)

This optimization is only legal if:
1) "Anything" is a sufficiently small constant itself.
2) We are in a context where we know the address will in
   fact be used for an indirection.

It is the second point that is problematic - one would
like to use MorphAddrContext, but it is not suitable
for this purpose, as an unknown context is counted as
an indirecting one. Additionally, the value of this
optimization is rather low. I am guessing it was meant
to support the legacy nullchecks, before GT_NULLCHECK
was introduced, and had higher impact then.

So, just remove the optimization and leave the 5 small
regressions across all of SPMI be.
src/coreclr/jit/morph.cpp
src/tests/JIT/Regression/JitBlue/Runtime_61510/Runtime_61510.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_61510/Runtime_61510.csproj [new file with mode: 0644]