From 19e0c52837ac9c676abdef6a17cb2b86e53b374f Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 27 Sep 2023 10:40:52 -0500 Subject: [PATCH] nak: Run simple liveness data-flow bottom-up Rookie mistake... The liveness algorithm propagates information from later blocks to earlier blocks so if you run bottom-up it's exactly two passes when there aren't loops. If you run top-down, it's quadratic in the number of blocks. Part-of: --- src/nouveau/compiler/nak_liveness.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nouveau/compiler/nak_liveness.rs b/src/nouveau/compiler/nak_liveness.rs index a2012c9d2fa..449abd4772f 100644 --- a/src/nouveau/compiler/nak_liveness.rs +++ b/src/nouveau/compiler/nak_liveness.rs @@ -314,7 +314,7 @@ impl SimpleLiveness { let mut to_do = true; while to_do { to_do = false; - for (b_idx, bl) in l.blocks.iter_mut().enumerate() { + for (b_idx, bl) in l.blocks.iter_mut().enumerate().rev() { /* Compute live-out */ for sb_idx in func.blocks.succ_indices(b_idx) { to_do |= bl.live_out.union_with(&live_in[*sb_idx]);