Skip to content

Commit eac6e90

Browse files
authored
Rollup merge of rust-lang#68790 - nnethercote:improve-merge_from_succ, r=nikomatsakis
Improve `merge_from_succ` A couple of small performance wins. r? @nikomatsakis
2 parents c79d72e + d62b6f2 commit eac6e90

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/librustc_passes/liveness.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,15 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
822822
return false;
823823
}
824824

825-
let mut changed = false;
825+
let mut any_changed = false;
826826
self.indices2(ln, succ_ln, |this, idx, succ_idx| {
827+
// This is a special case, pulled out from the code below, where we
828+
// don't have to do anything. It occurs about 60-70% of the time.
829+
if this.rwu_table.packed_rwus[succ_idx] == INV_INV_FALSE {
830+
return;
831+
}
832+
833+
let mut changed = false;
827834
let mut rwu = this.rwu_table.get(idx);
828835
let succ_rwu = this.rwu_table.get(succ_idx);
829836
if succ_rwu.reader.is_valid() && !rwu.reader.is_valid() {
@@ -843,6 +850,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
843850

844851
if changed {
845852
this.rwu_table.assign_unpacked(idx, rwu);
853+
any_changed = true;
846854
}
847855
});
848856

@@ -851,9 +859,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
851859
ln,
852860
self.ln_str(succ_ln),
853861
first_merge,
854-
changed
862+
any_changed
855863
);
856-
return changed;
864+
return any_changed;
857865
}
858866

859867
// Indicates that a local variable was *defined*; we know that no

0 commit comments

Comments
 (0)