fix: 池满时清 known 防陈旧值误折

This commit is contained in:
2026-10-12 15:20:48 +00:00
parent 7e7ee4f823
commit a862e381ec
3 changed files with 25 additions and 23 deletions
+3 -1
View File
@@ -143,13 +143,15 @@ pub fn fold_function(f: &mut IRFunction) -> bool {
};
if let Some(value) = folded {
// 新常量入池(去重加溢出守卫);池满时 A 组失效,跳过改写。
// 新常量入池(去重加溢出守卫);池满时 A 组失效,跳过改写并清 known。
if let Some(idx) = intern(constants, &value) {
*inst = Inst::load_const(inst.rd, idx);
changed = true;
if let Some(rd) = inst.def_reg() {
known[rd as usize] = Some(value);
}
} else if let Some(rd) = inst.def_reg() {
known[rd as usize] = None;
}
} else {
// B 组:逻辑短路(左操作数已知)→ 改写为 MOV。