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