-
Notifications
You must be signed in to change notification settings - Fork 13.3k
copied().min()
performance regression on nightly
#140207
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
Comments
Thanks for the bisect. It indeed looks to be caused by my patch. As the linked video indicates, this instruction is limited to min of This case is the oppose of what I was attempting to optimize For |
@rustbot label +I-libs-nominated I merged #139745 assuming that the precise behaviour around side-effects of the iterator methods was an implementation detail, but that should probably have been discussed beforehand. Also, it was the cause of this performance regression. T-libs, do you want to revert this change? |
We discussed this in the @rust-lang/libs meeting. We would like #139745 to be reverted for now and re-submitted with a libs-api nomination so that we can properly discuss the exact implications. I believe the reason this optimizes differently is that before #139745 the |
Some previous issues observing that by-reference slice iteration vectorizes poorly: |
By the way, I am not planning to submit the PRs for the revert or selective reintroduction, even though it's my bug. Sorry. The revert should be easy, though. I'm currently not looking to add any more PRs to my current stack. |
Code
I tried this code (godbolt, from this video):
I expected to see this happen: compiles to
vphminposuw
x86 instruction (+avx feature)Instead, this happened: compiles to unrolled cmp + cmov
Note that a manual
min
loop is unaffected, even with the slice iterator:Version it worked on
It most recently worked on: 1.86
Version with regression
rustc --version --verbose
:@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
searched nightlies: from nightly-2025-02-15 to nightly-2025-04-23
regressed nightly: nightly-2025-04-16
searched commit range: 2da29db...38c560a
regressed commit: 58c2dd9
Weirdly: #139745 cc @thaliaarchi
bisected with cargo-bisect-rustc v0.6.9
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
The text was updated successfully, but these errors were encountered: