Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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