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)
commite78d2fd7a533c5244e442fdaec032ca697fc8a97
treeb98dcdab9b917bb06ddaf347d5d89e4e02426409
parent69fcf9059b01b252027a4a0b5414b9a78bc13e7c
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.
src/jit/morph.cpp
tests/src/JIT/Regression/JitBlue/GitHub_12392/GitHub_12392.cs [new file with mode: 0644]
tests/src/JIT/Regression/JitBlue/GitHub_12392/GitHub_12392.csproj [new file with mode: 0644]