Optimize const
pattern guards for StructuralEq
types
#138664
Labels
A-patterns
Relating to patterns and pattern matching
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
With
inline_const_pat
being removed in #138492, it might be nice to optimize codegen ofpat if pat == const { .. }
.Right now
Produces a
SwitchInt
and then a separate equality check.Changing the second pattern to
7 => 100
produces 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_pat
gone).The text was updated successfully, but these errors were encountered: