Skip to content
New issue

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

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

Already on GitHub? # to your account

[mono][jit] Fix float to int32 casting overflow behavior #85316

Closed
jandupej opened this issue Apr 25, 2023 · 1 comment
Closed

[mono][jit] Fix float to int32 casting overflow behavior #85316

jandupej opened this issue Apr 25, 2023 · 1 comment
Assignees
Labels
area-Codegen-JIT-mono disabled-test The test is disabled in source code against the issue
Milestone

Comments

@jandupej
Copy link
Member

The issue has been encountered in #85163

The code private static float Z(float y) => (float)(int)y; translates on arm64 to:

...
000000000000001c        fcvtzs  x0, s0
0000000000000020        sxtw    x0, w0
0000000000000024        scvtf   s0, w0
...

Note the x0 in fcvtzs. The float value is cast to int64, then the lower half gets sign-extended. The expected behavior would be to directly convert to int32 with saturation, i.e.:

...
000000000000001c        fcvtzs  w0, s0
0000000000000020        scvtf   s0, w0
...

This would be more in line with the casting behavior of CoreCLR. This would also fix the test /JIT/SIMD/VectorConvert_ro_Target_64Bit/, which is to be reenabled at that point.

@jandupej jandupej added disabled-test The test is disabled in source code against the issue area-Codegen-JIT-mono labels Apr 25, 2023
@jandupej jandupej added this to the Future milestone Apr 25, 2023
@jandupej jandupej self-assigned this Apr 25, 2023
@jandupej
Copy link
Member Author

Fixed in the PR above.

@ghost ghost locked as resolved and limited conversation to collaborators Jul 22, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area-Codegen-JIT-mono disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

No branches or pull requests

1 participant