Auto merge of #96020 - martingms:optimize-relate_substs, r=nnethercote
Micro-optimize `ty::relate::relate_substs` by avoiding `match` Was a top-20 hot function in a callgrind profile of compiling `bitmaps-3.1.0`. Yields some small speedups on that crate and some others according to local benching: Benchmark | Profile | Scenario | % Change | Significance Factor? -- | -- | -- | -- | -- bitmaps-3.1.0 | check | full | -1.88% | 9.42x bitmaps-3.1.0 | debug | full | -1.80% | 8.99x bitmaps-3.1.0 | opt | full | -1.70% | 8.49x bitmaps-3.1.0 | check | incr-full | -1.54% | 7.68x deep-vector | debug | full | 1.52% | 7.61x bitmaps-3.1.0 | debug | incr-full | -1.45% | 7.26x bitmaps-3.1.0 | opt | incr-full | -1.39% | 6.95x nalgebra-0.30.1 | check | full | -0.68% | 3.42x nalgebra-0.30.1 | debug | full | -0.64% | 3.22x nalgebra-0.30.1 | opt | full | -0.64% | 3.20x projection-caching | check | full | -0.61% | 3.05x nalgebra-0.30.1 | check | incr-full | -0.56% | 2.78x nalgebra-0.30.1 | opt | incr-full | -0.54% | 2.72x nalgebra-0.30.1 | debug | incr-full | -0.54% | 2.69x projection-caching | check | incr-full | -0.50% | 2.51x tt-muncher | opt | full | -0.48% | 2.42x projection-caching | opt | full | -0.47% | 2.37x projection-caching | debug | full | -0.47% | 2.35x projection-caching | opt | incr-full | -0.44% | 2.21x projection-caching | debug | incr-full | -0.42% | 2.08x deeply-nested-multi | check | incr-full | 0.37% | 1.87x wf-projection-stress-65510 | opt | full | -0.37% | 1.84x deep-vector | debug | incr-patched: add vec item | -0.32% | 1.61x projection-caching | debug | incr-unchanged | -0.32% | 1.60x wf-projection-stress-65510 | check | full | -0.31% | 1.55x projection-caching | opt | incr-unchanged | -0.31% | 1.53x wf-projection-stress-65510 | debug | incr-full | -0.30% | 1.51x wf-projection-stress-65510 | opt | incr-full | -0.30% | 1.51x r? `@nnethercote`
This commit is contained in:
commit
c102c5cfc6
3 changed files with 36 additions and 25 deletions
|
@ -567,11 +567,17 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
|||
// Avoid fetching the variance if we are in an invariant
|
||||
// context; no need, and it can induce dependency cycles
|
||||
// (e.g., #41849).
|
||||
relate::relate_substs(self, None, a_subst, b_subst)
|
||||
relate::relate_substs(self, a_subst, b_subst)
|
||||
} else {
|
||||
let tcx = self.tcx();
|
||||
let opt_variances = tcx.variances_of(item_def_id);
|
||||
relate::relate_substs(self, Some((item_def_id, &opt_variances)), a_subst, b_subst)
|
||||
relate::relate_substs_with_variances(
|
||||
self,
|
||||
item_def_id,
|
||||
&opt_variances,
|
||||
a_subst,
|
||||
b_subst,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
|
|||
// performing trait matching (which then performs equality
|
||||
// unification).
|
||||
|
||||
relate::relate_substs(self, None, a_subst, b_subst)
|
||||
relate::relate_substs(self, a_subst, b_subst)
|
||||
}
|
||||
|
||||
fn relate_with_variance<T: Relate<'tcx>>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue