-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Combine instructions immediately #81101
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
r? @lcnr |
This makes sense to me given the scope of instcombine today, but I imagine this would make it significantly more difficult to instcombine multiple statements into one if we ever get to the point of wanting to do so. |
Thinking about it a little more: Given the structure of the MIR, having to use the same pass for both multi-statement and single-statement combines is probably an overall negative, mostly because there is likely a significant inherent cost associated with maintaining state for inst-combines that operate over multiple MIR statements (in LLVM its fine because its all pointers and referencing instructions is very cheap due to its SSA nature). So, it would make sense to me to have a separate pass for multi-statement instcombines once we start thinking about implementing those. On the other hand, in that world you'd probably want to run the two instcombines passes in a fixpoint anyway… so 🤷 cc @oli-obk |
Non-local transformation would require a different approach, but as long as we don't make them this approach has a benefit of making it clear that one transformation cannot invalidate another, since transforms are immediate and stateless. This is relatively trivial amount of code so we can always change this as a need arises. |
☔ The latest upstream changes (presumably #80865) made this pull request unmergeable. Please resolve the merge conflicts. |
No functional changes intended
@bors r+ |
📌 Commit 508eec4 has been approved by |
@bors rollup=never |
Should this get a perf run? |
I'm pretty confident this will be a net win due to the new code just doing less work walking the MIR structure. I still made it |
☀️ Test successful - checks-actions |
This is a mixed speedup (up to 0.6%) and slowdown (up to 1.3%): https://perf.rust-lang.org/compare.html?start=bbc01bb624a960533e049fdb98d0489ff2a8de06&end=f2de221b0063261140a336c448bf1421170c9a74&stat=instructions%3Au |
The perf results should show measurement error based on historical data, they are quite misleading otherwise. For example ctfe-stress-4-check which shows 1.3% slowdown never executes this code. Similarly debug and opt variants of this benchmark execute it only once on a MIR body with a single statement. |
No description provided.