Skip to content
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

Consider using std::min and std::max instead of fmin and fmax #1488

Open
dimitry-ishenko opened this issue Apr 1, 2024 · 2 comments
Open
Milestone

Comments

@dimitry-ishenko
Copy link

dimitry-ishenko commented Apr 1, 2024

fmin and fmax result in a function call on GCC and MSVC (or extra instructions on Clang).

Whereas, std::min and std::max map to single XMM instruction. I haven't bench-marked it, but it should definitely give performance boost.

Proof: https://godbolt.org/z/1jbPqbvGx

@dimitry-ishenko
Copy link
Author

NB: On Windows, you will need to define NOMINMAX somewhere at the top (or in the CMake file).

@hollasch hollasch added this to the Backlog milestone Apr 2, 2024
@eloj
Copy link

eloj commented Apr 8, 2024

I'll just note that this is one of those things that are affected by -ffast-math.

Specifically -ffinite-math-only seems to eliminate the call for GCC and clang at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants