-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Optimize const pattern guards for StructuralEq types #138664
Copy link
Copy link
Open
Labels
A-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-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-patternsRelating to patterns and pattern matchingRelating to patterns and pattern matchingC-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.
With
inline_const_patbeing removed in #138492, it might be nice to optimize codegen ofpat if pat == const { .. }.Right now
Produces a
SwitchIntand then a separate equality check.Changing the second pattern to
7 => 100produces a singleSwitchInt.I assume that the optimizer can recover this (at least for simpler cases), but it might be nice for the compiler to generate the simplified MIR directly (especially with
inline_const_patgone).