-
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
Math/MathF.Truncate isn't an intrinsic and results in inefficient codegen #56931
Comments
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsDescriptionMath/MathF.Truncate results in bad codegen that calls into native modf which is pretty slow. Instead, it should be an intrinsic for vroundsd/vroundss like Ceiling and Floor are (and clang also does do it for truncate). ConfigurationSharplab Core CLR 5.0.721.25508 on amd64 Regression?No idea. DataSharplab for Math
|
This should be a relatively simple fix but is going to be for 7.0.0 at the earliest. |
@MichalPetryka any interest in offering a PR? |
I've never worked with the JIT so I'd prefer somebody else to do it since I don't really know how sadly. |
Fair enough. Still, if you have an interest I expect @tannergooding could give pointers. 😄 |
Sure thing, here you go: |
This would be similar to the handling that exists for Basically if you search for Basically the only places that aren't adding in a new nearly identical path for It should be relatively straightforward overall and I'm happy to help walk you through it over DMs, the C# community discord (https://aka.ms/csharp-discord, specifically the |
Description
Math/MathF.Truncate results in bad codegen that calls into native modf which is pretty slow. Instead, it should be an intrinsic for vroundsd/vroundss like Ceiling and Floor are (and clang also does do it for truncate).
Configuration
Sharplab Core CLR 5.0.721.25508 on amd64
Regression?
No idea.
Data
Sharplab for Math
Sharplab for MathF
Godbolt clang for double
Godbolt clang for float
The text was updated successfully, but these errors were encountered: