Skip to content

[LoongArch64] Fix NativeAOT libs.tests failed cases in System.Runtime.Tests & System.Runtime.Numerics.Tests. #115598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025

Conversation

LuckyXu-HF
Copy link
Contributor

  • Fix the boundary overflow of imm+1 when imm = (~0) for Unsigned GT_LE/GT_GT in CodeGen::genCodeForCompare().
  • Fix the IntCastOverflowPositiveCheck with UINT32_MAX in CodeGen::genIntCastOverflowCheck().
  • Optimize CodeGen::genIntCastOverflowCheck() similar to riscv.

…System.Runtime.Numerics.Tests.

* Fix the boundary error with `imm = (~0)` for `Unsigned GT_LE/GT_GT` in `CodeGen::genCodeForCompare()`.
* Fix the IntCastOverflowPositiveCheck with `UINT32_MAX` in `CodeGen::genIntCastOverflowCheck()`.
* Optimize `CodeGen::genIntCastOverflowCheck()` similar to riscv.
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label May 15, 2025
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 15, 2025
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

@shushanhf shushanhf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jakobbotsch , could you please review this PR?

@LuckyXu-HF
Copy link
Contributor Author

The boundary failed testcases in NAOT-libs.tests of System.Runtime.Tests and System.Runtime.Numerics.Tests is:

failed testcases in NAOT-System.Runtime.Tests
...
  [FAIL] System.Tests.UInt128Tests_GenericMath.op_ModulusTest
  Assert.Equal() Failure: Values differ
  Expected: 1
  Actual:   340282366920938463444927863358058659841
     at System.Tests.UInt128Tests_GenericMath.op_ModulusTest() + 0x200
     at System.Runtime!<BaseAddress>+0x31a48dc
     at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x14c
  [SKIP] System.Tests.TypeTests.GetTypeByName_NonRoundtrippable
  [SKIP] System.Reflection.Tests.MethodBaseTests.TestMethodBody
  [FAIL] System.Tests.Int128Tests_GenericMath.DivRemTest
  Assert.Equal() Failure: Values differ
  Expected: Tuple (85070591730234615865843651857942052863, 1)
  Actual:   Tuple (85070591730234615865843651857942052863, -18446744073709551615)
     at System.Tests.Int128Tests_GenericMath.DivRemTest() + 0x274
     at System.Runtime!<BaseAddress>+0x31a48dc
     at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x14c
  [FAIL] System.Tests.Int128Tests_GenericMath.op_ModulusTest
  Assert.Equal() Failure: Values differ
  Expected: 1
  Actual:   -18446744073709551615
     at System.Tests.Int128Tests_GenericMath.op_ModulusTest() + 0x200
     at System.Runtime!<BaseAddress>+0x31a48dc
     at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x14c
  [FAIL] System.Tests.UInt128Tests_GenericMath.DivRemTest
  Assert.Equal() Failure: Values differ
  Expected: Tuple (85070591730234615865843651857942052863, 1)
  Actual:   Tuple (85070591730234615865843651857942052863, 340282366920938463444927863358058659841)
     at System.Tests.UInt128Tests_GenericMath.DivRemTest() + 0x274
     at System.Runtime!<BaseAddress>+0x31a48dc
     at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x14c
...
Tests run: 65669, Errors: 0, Failures: 4, Skipped: 119. Time: 16.9742184s
failed testcases in NAOT-System.Runtime.Numerics.Tests
...
  [FAIL] System.Numerics.Tests.cast_fromTest.RunUInt32ExplicitCastFromBigIntegerTests
  Assert.Throws() Failure: No exception was thrown
  Expected: typeof(System.OverflowException)
     at System.Numerics.Tests.cast_fromTest.RunUInt32ExplicitCastFromBigIntegerTests() + 0x204
     at System.Runtime.Numerics!<BaseAddress>+0xd89aec
     at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x14c
  [FAIL] System.Numerics.Tests.cast_fromTest.RunUInt64ExplicitCastFromBigIntegerTests
  Assert.Throws() Failure: Exception type was not an exact match
  Expected: typeof(System.OverflowException)
  Actual:   typeof(Xunit.Sdk.EqualException)
  ---- Assert.Equal() Failure: Values differ
  Expected: 18446744073709551615
  Actual:   4294967295
     at System.Numerics.Tests.cast_fromTest.RunUInt64ExplicitCastFromBigIntegerTests() + 0x224
     at System.Runtime.Numerics!<BaseAddress>+0xd89aec
     at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x14c
  ----- Inner Stack Trace -----
...
Tests run: 2627, Errors: 0, Failures: 2, Skipped: 1. Time: 46.9733519s

Fixed:
NAOT-System.Runtime.Tests: Tests run: 65669, Errors: 0, Failures: 0, Skipped: 119. Time: 13.0480331s
NAOT-System.Runtime.Numerics.Tests: Tests run: 2627, Errors: 0, Failures: 0, Skipped: 1. Time: 37.6802024s

@jakobbotsch jakobbotsch merged commit 30779a1 into dotnet:main May 15, 2025
111 checks passed
@LuckyXu-HF LuckyXu-HF deleted the main-LA64-NAOT branch May 15, 2025 07:49
@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-loongarch64 area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants