Uh oh!
There was an error while loading. Please reload this page.
MIR-opt: Generalize &(*_1) optimization to mutable references - #76802
MIR-opt: Generalize &(*_1) optimization to mutable references#76802simonvandel wants to merge 2 commits into
Conversation
_3 = &mut (*_1); can be _3 = _1 if _1 is of type &mut (which it is)
rust-highfive
commented
Sep 16, 2020
(rust_highfive has picked a reviewer for you, use r? to override) |
simonvandel
commented
Sep 16, 2020
Hmm I just saw 309661e where this was reverted. Not sure why yet |
jonas-schievink
commented
Sep 16, 2020
Because of #72797 |
simonvandel
commented
Sep 16, 2020
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 :) |
jonas-schievink
commented
Sep 16, 2020
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). |
simonvandel
commented
Sep 16, 2020
I'm curious about the measured performance and couldn't find anything on #72093. Do you remember where the perf run was performed? |
jonas-schievink
commented
Sep 16, 2020
That was a different issue, the fix was in #72820 |
simonvandel
commented
Sep 16, 2020
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? |
jonas-schievink
commented
Sep 16, 2020
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. |
bors
commented
Sep 20, 2020
☔ 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: |
Dylan-DPC-zz
commented
Oct 23, 2020
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 -lyields 10601, so it seems to be a fairly usable optimization on rust-std.