-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Avoid backtracking in "deref_of_address" MIR optimization #78368
Copy link
Copy link
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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.