diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/MathHelpers.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/MathHelpers.cs index d7195891320f00..7175ea9c00cbe2 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/MathHelpers.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/MathHelpers.cs @@ -164,6 +164,8 @@ public static long LMod(long i, long j) { if (j == 0) return ThrowLngDivByZero(); + else if (j == -1 && i == long.MinValue) + return ThrowLngOvf(); else return RhpLMod(i, j); } @@ -189,7 +191,7 @@ public static long LDiv(long i, long j) if (j == 0) return ThrowLngDivByZero(); else if (j == -1 && i == long.MinValue) - return ThrowLngArithExc(); + return ThrowLngOvf(); else return RhpLDiv(i, j); } @@ -205,12 +207,6 @@ private static ulong ThrowULngDivByZero() { throw new DivideByZeroException(); } - - [MethodImpl(MethodImplOptions.NoInlining)] - private static long ThrowLngArithExc() - { - throw new ArithmeticException(); - } #endif // TARGET_64BIT [RuntimeExport("Dbl2IntOvf")]