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