Fixes for bugs in fgMorphCast and optNarrowTree. (dotnet/coreclr#18816)
authorEugene Rozenfeld <erozen@microsoft.com>
Thu, 12 Jul 2018 20:42:00 +0000 (13:42 -0700)
committerGitHub <noreply@github.com>
Thu, 12 Jul 2018 20:42:00 +0000 (13:42 -0700)
commit5781f7518d5a1615adfdbf04b760574dbd4ccdf5
treeb3818d8927ed7f9ef23b4712f1bbb2c80d793c51
parent67839e5c11a1becbc5bb65dfc0786340c1ed2b5e
Fixes for bugs in fgMorphCast and optNarrowTree. (dotnet/coreclr#18816)

The fix under NARROW_IND prevents transformation of, e.g.,
CAST      int <- ushort <- int
    CLS_VAR byte

into

CLS_VAR byte.

With the fix the CAST is not removed.

The fix under GT_CAST prevents transformation of, e.g.,

CAST      int <- ushort <- long
    CAST      long <- int
       expr short

into

expt short.

With the fix it gets transformed into

CAST      int <- ushort <- int
    expr short

Block cast optimizations in fgMorphCast if the cast expression is an
active CSE candidate.

Update cast expression value numbers when a cast is removed.

Fixes dotnet/coreclr#18238, dotnet/coreclr#18850.

No diffs in frameworks and tests (pmi and crossgen, x64 and x86), except for the added test cases.

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