-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Do not attempt to commute comparison and cast to codegen discriminants #110197
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
r? @nikic |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit c92f9c97a31ea8aca28348ad4c1143e30e50a2d0 with merge a6684b582eded5f15890c6cf71312ac8a0fe555f... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
cc @mikebenfield who implemented this code in #102872 and #104535. |
Finished benchmarking commit (a6684b582eded5f15890c6cf71312ac8a0fe555f): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
@bors r+ It is clearly safe (if less efficient) to remove the special case branches as is done here, and the hit to compiler performance is acceptable given that it is fixing a soundness bug. Let think about getting this into the beta if we don't land it before the beta-branch of nightly (which will be happening either today or tomorrow is I understand correctly). So I'll beta-nom this ahead of time so that it doesn't get forgotten. @rustbot label: beta-nominated (And of course, anyone should feel free to try to readd a corrected version of this code, but definitely double check the cases described by #110128) |
📌 Commit 7c43b7011725d2898f15de6d7c70bdb414162234 has been approved by It is now in the queue for this repository. |
🔒 Merge conflict This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
☔ The latest upstream changes (presumably #109875) made this pull request unmergeable. Please resolve the merge conflicts. |
@bors r=pnkfelix |
☀️ Test successful - checks-actions |
Finished benchmarking commit (158c309): comparison URL. Overall result: ❌✅ regressions and improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
Removed the beta nomination as it landed in 1.70 already. |
The general algorithm to compute a discriminant is:
We have an optimization branch which attempts to merge the addition and the subtraction by commuting them with the cast. We currently get this optimization wrong.
This PR takes the easiest and safest way: remove the optimization, and let LLVM handle it. (Perf may not agree with that course of action 😅)
There may be a less invasive solution, but I don't have the necessary knowledge of LLVM semantics to find it. Cranelift has the same optimization, which should be handled similarly.
cc @nikic and @bjorn3 if you have a better solution.
Fixes #110128