-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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] Flush-to-zero behavior for float-to-int conversion #94762
[RISC-V] Flush-to-zero behavior for float-to-int conversion #94762
Conversation
… behavior for float-to-int conversion instruction
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsRISC-V specification does not provide option which enables flushing to zero return value of float-to-int conversion instructions in the case when input value is NaN or result can't be represented in the target type. Part of #84834
|
@DenisParal, I think there may have been a slight miscommunication. The behavior is not "any unrepresentable value becomes 0", but rather the behavior is |
In that case, I believe only the NaN behavior needs mending, this can be done branchless on RV, sth like:
|
@tomeksowi why is |
But it's 1 if not NaN, we need an all 1s mask (-1). |
Fixed flash-to-zero behavior to react only on NaN input. |
@tannergooding, I have tested |
As mentioned on the other threads that caused this PR, we are working on normalizing all platforms, including x64, to follow the standardized behavior. This work is tracked by #61885 The work to correctly handle x64 is being handled in parallel and will end up matching the stated behavior long term:
|
Please update code formatting with |
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.
The logic, assuming I understood the RISC-V instructions behavior correctly; looks correct to me.
Someone from @dotnet/jit-contrib needs to review/sign-off on the other changes.
A lot of System.Tests.UriMethodTests are failed with last commit, I work on fixing it. |
@DenisParal
|
@clamp03, thank you for suggestion, it looks better than my solution. coreclr tests are passed thus remove draft status. |
@jakobbotsch could you please review this PR? |
@@ -50,6 +50,7 @@ REGDEF(T5, 30, 0x40000000, "t5" ) | |||
REGDEF(T6, 31, 0x80000000, "t6" ) | |||
|
|||
REGALIAS(R8, FP) | |||
REGALIAS(ZERO, R0) |
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.
Is this a common/official alias?
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.
It is official according to RISC-V specification.
https://riscv.org/wp-content/uploads/2015/01/riscv-calling.pdf
RISC-V specification does not provide option which enables flushing to zero return value of float-to-int conversion instructions in the case when input value is NaN or result can't be represented in the target type.
Thus we need to enable this option to support deterministic behavior across platforms.
Part of #84834
cc @gbalykov @t-mustafin @clamp03 @tomeksowi @brucehoult @tannergooding