rust-gpu icon indicating copy to clipboard operation
rust-gpu copied to clipboard

structurizer: split regions into `Divergent` vs `Convergent`, and optimize based on that.

Open eddyb opened this issue 4 years ago • 0 comments

The first commit is a pretty large refactor that ended up a bit worse than I expected. We might just want to have this instead (and call it in a few places):

impl Region {
    fn diverges(&self) -> bool {
        self.exits.is_empty()
    }
}

The second commit is just an on-the-fly OpPhi simplification that we should probably merge completely separately.

And the third commit is "clever hack" (to remove some unnecessary empty blocks, see example below) that could also probably be done without the first commit, it just didn't hit me that it was possible before the refactor.

(click to open example code & before/after graphs for the third commit)
pub fn marker() {}

pub fn shortcircuit_and(a: bool, b: bool) {
    if a && b {
        marker();
    }
}

Before

After

eddyb avatar Apr 01 '21 07:04 eddyb