Fix for a bug in fgMorphRecognizeBoxNullable.
authorEugene Rozenfeld <erozen@microsoft.com>
Tue, 20 Jun 2017 23:46:02 +0000 (16:46 -0700)
committerEugene Rozenfeld <erozen@microsoft.com>
Wed, 21 Jun 2017 05:35:56 +0000 (22:35 -0700)
commitcb77d0ed19e8a32925701d5e561d59ac4b8af0b9
treebc2aa69a642cd05822dfe15ca800cb8272ae9f44
parente88fc895cca39355be44d83f5d57610e6fdd1f4a
Fix for a bug in fgMorphRecognizeBoxNullable.

fgMorphRecognizeBoxNullable doesn't work correctly when called during re-morphing. In particular it can't handle late args in the call to CORINFO_HELP_BOX_NULLABLE. The test case results in several asserts (the first one in lsra) followed by an infinite loop in the jit.

The reason the optimization is not performed during global morph is that only patterns with GT_EQ and GT_NE are handled. Some versions of csc generate

...
ldnull
cgt.un
ret

for

this C# line

null != this.value

so we get GT_GT instead.

The fix has two parts:

1. Don't attempt to perform the optimization when called during re-morph and the struct parameter is a late arg.
2. Call fgMorphRecognizeBoxNullable for GT_GT nodes with GTF_UNSIGNED set. This allows the optimization to fire during global morph.

Commit migrated from https://github.com/dotnet/coreclr/commit/e78d2fd7a533c5244e442fdaec032ca697fc8a97
src/coreclr/src/jit/morph.cpp
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_12392/GitHub_12392.cs [new file with mode: 0644]
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_12392/GitHub_12392.csproj [new file with mode: 0644]