Skip to content

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

Open
@oli-obk

Description

@oli-obk

#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions