Closed
Description
Description
The following program gives a wrong result when optimizing:
Reproduction Steps
// Debug: 80
// Release: ffff0080
using System.Buffers.Binary;
short[] foo = { short.MinValue };
int test = BinaryPrimitives.ReverseEndianness(foo[0]);
System.Console.WriteLine(test.ToString("x"));
Expected behavior
Same result.
Actual behavior
Different results.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
We do insert the cast when we import. Looks like value numbering ends up assigning the same liberal VN to the cast
and the bswap16
and CSE then effectively removes the sign extension.