perf: live 集改 u64 位集 + 不动点缓冲复用

LiveInfo 四矩阵由逐位 Vec<bool>(1 字节/位,长度 = max_vreg+1)改为
u64 压缩位集(1 字 64 位,长度 ÷8),dataflow 不动点 out/input 缓冲
提为循环外复用(clear + 覆盖,免逐迭代逐块分配)。dce_precise /
graph 建图 / call_window 三处消费方同步改为字内位移查询,越界语义
与旧 Vec<bool>::get 一致(越界 = 不 live)。位集遍历(call_window
存活上界)按 trailing_zeros 只走实际置位,活集小则近 O(活集) 而非
O(254)。

实测(debug,start-unicode-17.0.0.js):liveness 三趟合计
~536ms → ~118ms(-78%),矩阵内存 ÷8;graph 全 node 扫描为剩余
瓶颈,另行跟进。
This commit is contained in:
2026-08-16 03:20:02 +08:00
parent 3962a329bd
commit b8611d2c4b
8 changed files with 117 additions and 82 deletions
+6 -5
View File
@@ -39,7 +39,7 @@ pub(super) fn pass_dead_with_liveness(f: &IRFunction, live: &LiveInfo, keep: &mu
continue;
}
let after = &live.inst_live_after[i];
let not_live_after = |r: u32| !after.get(r as usize).copied().unwrap_or(false);
let not_live_after = |r: u32| !oxide_liveness::bitset_get(after, r as usize);
// 通用规则:纯指令结果不被后续使用 → 删(is_pure=false 已防 CALL/SPILL/UNSPILL)
if let Some(r) = inst.def_reg() {
if not_live_after(r) && inst.is_pure(f) {
@@ -72,14 +72,15 @@ mod tests {
use crate::dce_precise;
use oxide_ir::inst::Inst;
/// helper:稀疏号集 → bitset live_after。
fn live_sets(after: &[&[u32]], reg_count: usize) -> Vec<Vec<bool>> {
/// helper:稀疏号集 → u64 位集 live_after。
fn live_sets(after: &[&[u32]], reg_count: usize) -> Vec<Vec<u64>> {
let words = (reg_count + 1).div_ceil(64);
after
.iter()
.map(|set| {
let mut v = vec![false; reg_count + 1];
let mut v = vec![0u64; words];
for &r in *set {
v[r as usize] = true;
v[(r as usize) >> 6] |= 1u64 << ((r as usize) & 63);
}
v
})