MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / dce_phi

Function dce_phi

crates/rustc_codegen_spirv/src/linker/dce.rs:140–162  ·  view source on GitHub ↗
(func: &mut Function)

Source from the content-addressed store, hash-verified

138}
139
140pub fn dce_phi(func: &mut Function) {
141 let mut used = FxIndexSet::default();
142 loop {
143 let mut changed = false;
144 for inst in func.all_inst_iter() {
145 if inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap()) {
146 for op in &inst.operands {
147 if let Some(id) = op.id_ref_any() {
148 changed |= used.insert(id);
149 }
150 }
151 }
152 }
153 if !changed {
154 break;
155 }
156 }
157 for block in &mut func.blocks {
158 block
159 .instructions
160 .retain(|inst| inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap()));
161 }
162}
163
164fn instruction_is_pure(inst: &Instruction) -> bool {
165 use Op::*;

Callers 1

mem2regFunction · 0.85

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected