Skip to content

Commit 9a767b6

Browse files
committed
Auto merge of #110820 - cjgillot:faster-dcp, r=oli-obk
Optimize dataflow-const-prop place-tracking infra Optimization opportunities found while investigating #110719 Computing places breadth-first ensures that we create short projections before deep projections, since the former are more likely to be propagated. The most relevant is the pre-computation of flooded places. Callgrind showed `flood_*` methods and especially `preorder_preinvoke` were especially hot. This PR attempts to pre-compute the set of `ValueIndex` that `preorder_invoke` would visit. Using this information, we make some `PlaceIndex` inaccessible when they contain no `ValueIndex`, allowing to skip computations for those places. cc `@jachris` as original author
2 parents cba1407 + ccc1da2 commit 9a767b6

File tree

3 files changed

+183
-141
lines changed

3 files changed

+183
-141
lines changed

compiler/rustc_mir_dataflow/src/framework/lattice.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ pub trait MeetSemiLattice: Eq {
7575

7676
/// A set that has a "bottom" element, which is less than or equal to any other element.
7777
pub trait HasBottom {
78-
fn bottom() -> Self;
78+
const BOTTOM: Self;
7979
}
8080

8181
/// A set that has a "top" element, which is greater than or equal to any other element.
8282
pub trait HasTop {
83-
fn top() -> Self;
83+
const TOP: Self;
8484
}
8585

8686
/// A `bool` is a "two-point" lattice with `true` as the top element and `false` as the bottom:
@@ -113,15 +113,11 @@ impl MeetSemiLattice for bool {
113113
}
114114

115115
impl HasBottom for bool {
116-
fn bottom() -> Self {
117-
false
118-
}
116+
const BOTTOM: Self = false;
119117
}
120118

121119
impl HasTop for bool {
122-
fn top() -> Self {
123-
true
124-
}
120+
const TOP: Self = true;
125121
}
126122

127123
/// A tuple (or list) of lattices is itself a lattice whose least upper bound is the concatenation
@@ -274,13 +270,9 @@ impl<T: Clone + Eq> MeetSemiLattice for FlatSet<T> {
274270
}
275271

276272
impl<T> HasBottom for FlatSet<T> {
277-
fn bottom() -> Self {
278-
Self::Bottom
279-
}
273+
const BOTTOM: Self = Self::Bottom;
280274
}
281275

282276
impl<T> HasTop for FlatSet<T> {
283-
fn top() -> Self {
284-
Self::Top
285-
}
277+
const TOP: Self = Self::Top;
286278
}

0 commit comments

Comments
 (0)