You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mono (observed on the LLVM AOT configuration) does not preserve the sign of zero when lowering Min / MinNumber for floating-point types. Per the BCL contract, double.Min(+0.0, -0.0) (and the float/MinNumber variants) must return -0.0, treating -0.0 as less than +0.0. Mono instead returns +0.0.
Reproduction
usingSystem;usingSystem.Runtime.CompilerServices;[MethodImpl(MethodImplOptions.NoInlining|MethodImplOptions.AggressiveOptimization)]staticdoubleMinNegZeroConst(doublevalue)=>double.Min(value,-0.0);// Expected: -9223372036854775808 (bits of -0.0)// Mono LLVM AOT actual: 0 (bits of +0.0)Console.WriteLine(BitConverter.DoubleToInt64Bits(MinNegZeroConst(+0.0)));
The same divergence affects float.Min, double.MinNumber, and float.MinNumber.
Analysis
This surfaced in the CI for #130832: the regression test Runtime_130831 (added to validate a CoreCLR JIT constant-folding fix) fails on the AllSubsets_Mono_LLVMAot_RuntimeTests leg with:
Expected: -9223372036854775808
Actual: 0
The test has been marked [SkipOnMono] referencing this issue so it continues to validate the CoreCLR fix while the Mono divergence is tracked here.
Description
Mono (observed on the LLVM AOT configuration) does not preserve the sign of zero when lowering
Min/MinNumberfor floating-point types. Per the BCL contract,double.Min(+0.0, -0.0)(and thefloat/MinNumbervariants) must return-0.0, treating-0.0as less than+0.0. Mono instead returns+0.0.Reproduction
The same divergence affects
float.Min,double.MinNumber, andfloat.MinNumber.Analysis
This surfaced in the CI for #130832: the regression test
Runtime_130831(added to validate a CoreCLR JIT constant-folding fix) fails on theAllSubsets_Mono_LLVMAot_RuntimeTestsleg with:The test has been marked
[SkipOnMono]referencing this issue so it continues to validate the CoreCLR fix while the Mono divergence is tracked here.Configuration
AllSubsets_Mono_LLVMAot_RuntimeTests), linux-x64 Release.Note
This issue was authored with the assistance of GitHub Copilot.