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

<random>: Optimize range adjustment in uniform_int #4234

Merged
merged 1 commit into from
Dec 7, 2023
Merged

<random>: Optimize range adjustment in uniform_int #4234

merged 1 commit into from
Dec 7, 2023

Conversation

horenmar
Copy link
Contributor

@horenmar horenmar commented Dec 4, 2023

Neither Clang nor MSVC is smart enough to optimize the previous code into the simple non-branching non-conditional move variant. (GCC actually is, but GCC does not matter in this context)

See
https://godbolt.org/z/T9GT7s5rG
https://godbolt.org/z/eE7q9G9W8


Comment on the PR instructions:

I am working on custom distributions for Catch2, and implemented the range adjustment like this. Afterwards I went to check how the STLs do it and quick test showed that MSVC is better served with my implementation. Since this started as my original work, even though for different repo, I think that's fine.

Neither Clang nor MSVC is smart enough to optimize the previous
code into the simple non-branching non-conditional move variant.
(GCC actually is, but GCC does not matter in this context)

See
https://godbolt.org/z/T9GT7s5rG
https://godbolt.org/z/eE7q9G9W8
@horenmar horenmar requested a review from a team as a code owner December 4, 2023 20:04
@CaseyCarter CaseyCarter added the performance Must go faster label Dec 5, 2023
@CaseyCarter
Copy link
Member

We usually ask for benchmarks to support performance improvement PRs, but I think codegen inspection suffices here. Thanks!

@StephanTLavavej StephanTLavavej self-assigned this Dec 7, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit f89e70e into microsoft:main Dec 7, 2023
37 checks passed
@StephanTLavavej
Copy link
Member

Thanks for improving the performance of everyone's favorite distribution, and congratulations on your first microsoft/STL commit! 😻 🚀 🎉

This will ship in VS 2022 17.10 Preview 1.

@horenmar horenmar deleted the better-uniform-int-range-adjust branch December 8, 2023 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants