Skip to content

[mir-opt] optimization idea: bubble return terminators to predecessor blocks #72022

Closed
@oli-obk

Description

@oli-obk

cc @rust-lang/wg-mir-opt

if we have a basic block with no statements and just a return terminator, any other basic block that just gotos into that block could just as well call return itself. Or do we have some rule that we can only have a single return terminator per mir::Body?

Maybe we can generalize this and bubble any terminator of a statement-less block into its predecessor terminators iff that predecessor terminator is a goto.

As an example take

which is a basic block with no statements and just a return terminator, and both predecessor blocks have a goto to this block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.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