-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[RISC-V] Fix floating point #88311
[RISC-V] Fix floating point #88311
Conversation
@jakobbotsch I have a question. While I fix issues in In some tests like I checked converting runtime/src/coreclr/jit/importercalls.cpp Line 3797 in f25bc7b
NI_System_BitConverter_SingleToInt32Bits is too. It converts to canonical NaN 0x7fc00000 of float when copying gtDconVal to float variable. So the return value of NI_System_BitConverter_SingleToInt32Bits is not -1 anymore.The same problem occurs in all code locations which copying float value from/to GenTreeDblCon such as assertionprops, emit, and etc.
This is a simple cpp example.
RISCV: Thank you. |
@clamp03 @tannergooding will know more (but he's on vacation I believe, so might be a bit before he can get back to you). But my understanding is that the JIT relies on floating point conversions to preserve payload bits in NaNs, which is the behavior (I believe) for all our existing hosts. There may be relatively few places within the JIT where such conversions happen, in which case we might be ok with a software implementation for RISC-V. However I'm not sure how the behavior extends for other operations; I don't think we would be happy about shipping a whole floating point emulation library with the JIT to align the behavior if there is a widespread difference in NaN handling. |
While NaN canonicalization is "technically allowed" by the IEEE 754 spec it is not recommended and there is a large amount of code that relies on The RISC-V spec calls mention to an explicit decision to not propagate:
That being said, RISC-V does preserve in some cases such as It is very likely that the IR generated for "bitcasting" and some other scenarios needs to take this into account and explicitly preserve the bits involved on |
Its also worth noting that RISC-V does define It's possible that the codegen for holding a |
@jakobbotsch @tannergooding Thank you for the comments. Based on the comments, I will investigate C/C++ source in runtime and machine code generated by JITC again. Then fix those codes to use instructions which preserve the NaN payload in other PR. Could you review this PR and merge? Thank you. @shushanhf Changed near to TARGET_LOONGARCH64, maybe you would better to review before merge it. |
This PR is OK for LA64. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
TARGET_RISCV64
definition and fix a typo.Below tests pass
Part of #84834
cc @wscho77 @HJLeee @JongHeonChoi @t-mustafin @alpencolt @gbalykov