Skip to content
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

Move StorageDead/StorageLive around to allow more optimizations to trigger #78285

Open
oli-obk opened this issue Oct 23, 2020 · 1 comment
Open
Labels
A-mir-opt Area: MIR optimizations C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Oct 23, 2020

#78191 fixes a bug in MatchBranchSimplification but causes it to create some "boilerplate". We should try to optimize it away again. One example is

-         switchInt(_4) -> [false: bb7, otherwise: bb8];
+         StorageLive(_9);
+         _9 = _4;
+         _3 = Ne(_9, const false);
+         StorageDead(_9);
+         goto -> bb9;

for which we should make sure that copy prop still manages to remove _9.

Other situations are

-         switchInt(move _3) -> [false: bb11, otherwise: bb10];
+         StorageLive(_10);
+         _10 = move _3;
+         StorageDead(_3);
+         _1 = Ne(_10, const false);
+         StorageDead(_10);
+         goto -> bb12;

which are more complex. But since it is always safe (haha, uh, I think) to move a StorageDead further down and a StorageLive further up, we should be able to move the StorageDead(_3) after _1 = Ne(_10, const false);, thus allowing copy prop to handle this again.

@oli-obk oli-obk added the A-mir-opt Area: MIR optimizations label Oct 23, 2020
@jonas-schievink
Copy link
Contributor

cc #68622

@Enselic Enselic added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants