Fix value number update in fgMorphCast. (dotnet/coreclr#19226)
authorEugene Rozenfeld <erozen@microsoft.com>
Wed, 1 Aug 2018 22:48:41 +0000 (15:48 -0700)
committerGitHub <noreply@github.com>
Wed, 1 Aug 2018 22:48:41 +0000 (15:48 -0700)
commitb9effd47a1010533db0a8ffacb2c9cea2f5d8950
tree09c99852e684fe2b52ea4eef8eb72e7ee115b298
parente4db0db92e0c869c57c826b1926e982418037594
Fix value number update in fgMorphCast. (dotnet/coreclr#19226)

removing GT_CAST nodes. It caused a problem for cases
where GT_CAST operand is a constant (e.g., GT_CNS_INT). In these
cases the value number shouldn't change since there is an
assumption that constant nodes have known constant value numbers.

The bug was found by ILGEN, I created a corresponding C# repro.
Without the fix this assert fires: https://github.com/dotnet/coreclr/blob/dotnet/coreclr@1f28125ad1f9975fbe68dd6839908aa6e63fc43b#gitext://gotocommit/dotnet/coreclr@1f28125ad1f9975fbe68dd6839908aa6e63fc43b/src/jit/assertionprop.cpp#L2687

The fix is to update value numbers only when we changed the operand of GT_CAST and
value number wasn't updated otherwise (e.g., in optNarrowTree).

I verified no x64 diffs in
jit-diff diff  --pmi --tests --frameworks
(with pri0 and pri1 tests).

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