Skip to content

Commit

Permalink
Auto merge of rust-lang#110820 - cjgillot:faster-dcp, r=oli-obk
Browse files Browse the repository at this point in the history
Optimize dataflow-const-prop place-tracking infra

Optimization opportunities found while investigating rust-lang#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
  • Loading branch information
bors committed May 10, 2023
2 parents cba1407 + ccc1da2 commit 9a767b6
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 141 deletions.
20 changes: 6 additions & 14 deletions compiler/rustc_mir_dataflow/src/framework/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ pub trait MeetSemiLattice: Eq {

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

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

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

impl HasBottom for bool {
fn bottom() -> Self {
false
}
const BOTTOM: Self = false;
}

impl HasTop for bool {
fn top() -> Self {
true
}
const TOP: Self = true;
}

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

impl<T> HasBottom for FlatSet<T> {
fn bottom() -> Self {
Self::Bottom
}
const BOTTOM: Self = Self::Bottom;
}

impl<T> HasTop for FlatSet<T> {
fn top() -> Self {
Self::Top
}
const TOP: Self = Self::Top;
}
Loading

0 comments on commit 9a767b6

Please sign in to comment.