From f1d0743d1490ff7e0eeab4defaec31395ee0b8de Mon Sep 17 00:00:00 2001 From: Christoph Burgdorf Date: Mon, 9 Mar 2026 09:49:55 +0000 Subject: [PATCH] Handle multi-result insts in aggregate cleanup --- crates/codegen/src/optim/aggregate/cleanup.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/codegen/src/optim/aggregate/cleanup.rs b/crates/codegen/src/optim/aggregate/cleanup.rs index d46187c6..65eae897 100644 --- a/crates/codegen/src/optim/aggregate/cleanup.rs +++ b/crates/codegen/src/optim/aggregate/cleanup.rs @@ -55,15 +55,18 @@ fn is_dead_pure_inst(func: &Function, inst: InstId) -> bool { return false; } - let Some(result) = func.dfg.inst_result(inst) else { + let results = func.dfg.inst_results(inst); + if results.is_empty() { return false; - }; + } - !func - .dfg - .users(result) - .copied() - .any(|user| func.layout.is_inst_inserted(user)) + results.iter().copied().all(|result| { + !func + .dfg + .users(result) + .copied() + .any(|user| func.layout.is_inst_inserted(user)) + }) } fn inst_operands(func: &Function, inst: InstId) -> SmallVec<[ValueId; 8]> {