Skip to content

Update CoreCLR interpreter float->int saturation to match JIT #116834

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kg
Copy link
Member

@kg kg commented Jun 19, 2025

See #116823
The test for this was causing outerloop failures because the interpreter's expected behavior does not match ryujit. The best course of action right now is to make the interpreter match ryujit so the test can be re-enabled on outerloop.

Copy link
Contributor

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

@kg kg marked this pull request as ready for review June 20, 2025 19:52
@Copilot Copilot AI review requested due to automatic review settings June 20, 2025 19:52
@kg kg requested review from BrzVlad and janvorli as code owners June 20, 2025 19:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the CoreCLR interpreter’s floating-point→integer conversion to use a saturating conversion via an intermediate type and adjusts the existing test so that it fails when the interpreter behavior does not match RyuJIT.

  • Invert the test assertion in TestConvBoundaries for sub-Int32 conversions.
  • Generalize ConvFpHelper to take an intermediate integer type (TIntermediate) and update all call sites accordingly.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/tests/JIT/interpreter/Interpreter.cs Invert the if check on (a, b) and add a comment referencing the JIT mismatch issue
src/coreclr/vm/interpexec.cpp Change ConvFpHelper signature to accept TIntermediate and modify its logic and call sites
Comments suppressed due to low confidence (1)

src/coreclr/vm/interpexec.cpp:172

  • Consider adding unit tests for the new 64-bit conversion paths (e.g., INTOP_CONV_I8_R4, INTOP_CONV_U8_R8) to ensure the TIntermediate-based saturation logic behaves correctly for large result types.
template <typename TResult, typename TIntermediate, typename TSource> static void ConvFpHelper(int8_t *stack, const int32_t *ip)

@@ -1540,8 +1540,11 @@ public static bool TestConvBoundaries (double inRangeShort, double outOfRangeSho
int c = (int)inRangeInt,
d = (int)outOfRangeInt;

if (a != b)
// See https://github.com/dotnet/runtime/issues/116823 - they should *not* currently match if target size is smaller than int32
// if (a != b)
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

[nitpick] Remove the commented-out condition or add a // TODO explaining when and why it will be reverted; leaving the old if (a != b) in comments may confuse future maintainers.

Suggested change
// if (a != b)
// TODO: The condition `if (a != b)` was commented out due to the behavior described in issue #116823.
// Revisit this condition if the issue is resolved and the behavior changes.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant