JIT: (bug) negating division by the signed minimum gives the wrong result
Open
area-CodeGen-coreclr
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
## Repro
```csharp
using System;
using System.Runtime.CompilerServices;
class Program {
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
static int Test(int x) => -(x / int.MinValue);
static void Main() {
Console.WriteLine(Test(int.MinValue));
}
}
```
## Expected
```
-1
```
`int.MinValue / int.MinValue` is `1`, negated is `-1`.
## Actual
```
1
```
## Platform
Windows x64, .NET 11.0.0-rc.1.26425.128. Also affects `long` and `nint`.
Contributor guide
Assessment
This issue has not been assessed yet.