Skip to content

Avoid backtracking in "deref_of_address" MIR optimization #78368

Closed
@simonvandel

Description

@simonvandel

The current implementation of "deref_of_address" introduced in #76683 uses a backtracking algorithm.
That is, it first tries to locate a dereference of a local, e.g. _2 = (*_1). It then backtracks the previous statements for a definition of _1. The current implementation has an heuristic look-back value of 6, which is arbitrarily chosen.

We should instead walk the statements in the order they appear in the basic blocks, keeping track of places where the optimization could be applied. This should both be faster since we only look at each statement once. And it will apply more optimizations as the heuristic look-back value is gone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-mir-optArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchT-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