Fix floating point <-> integer conversions#116236
Merged
Merged
Conversation
This change uses JIT helpers to implement the floating point to integer and vice versa conversions.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR aims to fix and standardize the floating point to integer (and vice versa) conversion logic by leveraging JIT helper functions.
- Introduced new FCDECL helper calls for various conversion scenarios.
- Replaced traditional cast-based conversions with helper calls via HCCALL1.
- Implemented previously unhandled conversion cases (e.g., UINT conversions) by replacing assert(0) with helper calls.
Comments suppressed due to low confidence (3)
src/coreclr/vm/interpexec.cpp:250
- The conversion now employs HCCALL1(JIT_Dbl2Int, ...) for converting a float to int, replacing a direct cast. Please verify that the helper function preserves the intended conversion semantics compared to the previous implementation.
LOCAL_VAR(ip[1], int32_t) = (int8_t)HCCALL1(JIT_Dbl2Int, (double)LOCAL_VAR(ip[2], float));
src/coreclr/vm/interpexec.cpp:318
- Replacing the previous assert(0) with a helper call for INTOP_CONV_U4_R8 alters the behavior. Please ensure that JIT_Dbl2UInt correctly handles the conversion edge cases that were originally unimplemented.
LOCAL_VAR(ip[1], uint32_t) = HCCALL1(JIT_Dbl2UInt, LOCAL_VAR(ip[2], double));
src/coreclr/vm/interpexec.cpp:366
- Replacing the TODO and assert(0) in INTOP_CONV_U8_R8 with a helper call changes the conversion behavior. Confirm that JIT_Dbl2ULng implements the intended logic for converting a double to an unsigned long.
LOCAL_VAR(ip[1], uint64_t) = HCCALL1(JIT_Dbl2ULng, LOCAL_VAR(ip[2], double));
kg
approved these changes
Jun 3, 2025
BrzVlad
approved these changes
Jun 3, 2025
Member
Author
|
/ba-g #116261 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change uses JIT helpers to implement the floating point to integer and vice versa conversions.