-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
MIR-opt: Generalize &(*_1) optimization to mutable references #76802
MIR-opt: Generalize &(*_1) optimization to mutable references #76802
Conversation
_3 = &mut (*_1); can be _3 = _1 if _1 is of type &mut (which it is)
(rust_highfive has picked a reviewer for you, use r? to override) |
Hmm I just saw 309661e where this was reverted. Not sure why yet |
Because of #72797 |
So the problem is that it is only valid to optimize Alternatively, I'll close this PR - but it's more fun to drive this to something sound :) |
You'd have to compute liveness of locals, which isn't too difficult. But since this optimization had no measurable performance benefits anyways, I'm not sure that's worth it (running dataflow might slightly regress performance). |
I'm curious about the measured performance and couldn't find anything on #72093. Do you remember where the perf run was performed? |
That was a different issue, the fix was in #72820 |
Thanks. The results surprise me. I'm wondering if things have changed since then - it seemed like the observed changes could be explained by different CGU partitioning. Taking your rustc experience in mind, do you think it is worth continuing with this PR, or should I just close it? |
Hmm, I would probably not make this use dataflow at this point. Maybe if we can use the dataflow results to do more things this would be more worthwhile. |
☔ The latest upstream changes (presumably #72632) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
thanks for taking the time to contribute. I have to close this due to inactivity. If you wish and you have the time you can open a new PR with these changes and we'll take it from there. Thanks |
Running
RUSTC_LOG=rustc_mir::transform::instcombine ./x.py test --stage 1 src/test/mir-opt --bless | grep "replacing \`&mut*" | wc -l
yields 10601, so it seems to be a fairly usable optimization on rust-std.