nak: Don't allocate bitsets in liveness data-flow

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand 2023-09-27 10:41:59 -05:00 committed by Marge Bot
parent 04658a2a11
commit 827dba398d
2 changed files with 14 additions and 3 deletions

View file

@ -497,6 +497,10 @@ impl SSAValueAllocator {
SSAValueAllocator { count: 0 } SSAValueAllocator { count: 0 }
} }
pub fn max_idx(&self) -> u32 {
self.count
}
pub fn alloc(&mut self, file: RegFile) -> SSAValue { pub fn alloc(&mut self, file: RegFile) -> SSAValue {
self.count += 1; self.count += 1;
SSAValue::new(file, self.count) SSAValue::new(file, self.count)

View file

@ -311,6 +311,10 @@ impl SimpleLiveness {
assert!(l.blocks.len() == func.blocks.len()); assert!(l.blocks.len() == func.blocks.len());
assert!(live_in.len() == func.blocks.len()); assert!(live_in.len() == func.blocks.len());
let num_ssa = usize::try_from(func.ssa_alloc.max_idx() + 1).unwrap();
let mut tmp = BitSet::new();
tmp.reserve(num_ssa);
let mut to_do = true; let mut to_do = true;
while to_do { while to_do {
to_do = false; to_do = false;
@ -320,10 +324,13 @@ impl SimpleLiveness {
to_do |= bl.live_out.union_with(&live_in[*sb_idx]); to_do |= bl.live_out.union_with(&live_in[*sb_idx]);
} }
let new_live_in = tmp.clear();
(bl.live_out.clone() | bl.uses.clone()) & !bl.defs.clone(); tmp.set_words(0..num_ssa, |w| {
(bl.live_out.get_word(w) | bl.uses.get_word(w))
& !bl.defs.get_word(w)
});
to_do |= live_in[b_idx].union_with(&new_live_in); to_do |= live_in[b_idx].union_with(&tmp);
} }
} }