diff --git a/lib/cretonne/src/simple_gvn.rs b/lib/cretonne/src/simple_gvn.rs index 40d0ecf527..20e2298440 100644 --- a/lib/cretonne/src/simple_gvn.rs +++ b/lib/cretonne/src/simple_gvn.rs @@ -7,8 +7,9 @@ use std::collections::HashMap; /// Test whether the given opcode is unsafe to even consider for GVN. fn trivially_unsafe_for_gvn(opcode: Opcode) -> bool { - opcode.is_call() || opcode.is_branch() || opcode.is_terminator() || opcode.is_return() || - opcode.can_trap() || opcode.other_side_effects() + opcode.is_call() || opcode.is_branch() || opcode.is_terminator() || + opcode.is_return() || opcode.can_trap() || opcode.other_side_effects() || + opcode.can_store() || opcode.can_load() } /// Perform simple GVN on `func`. @@ -26,24 +27,15 @@ pub fn do_simple_gvn(func: &mut Function, cfg: &mut ControlFlowGraph, domtree: & pos.goto_top(ebb); while let Some(inst) = pos.next_inst() { - let opcode = func.dfg[inst].opcode(); - let ctrl_typevar = func.dfg.ctrl_typevar(inst); - // Resolve aliases, particularly aliases we created earlier. func.dfg.resolve_aliases_in_arguments(inst); + let opcode = func.dfg[inst].opcode(); if trivially_unsafe_for_gvn(opcode) { continue; } - // TODO: Implement simple redundant-load elimination. - if opcode.can_store() { - continue; - } - if opcode.can_load() { - continue; - } - + let ctrl_typevar = func.dfg.ctrl_typevar(inst); let key = (func.dfg[inst].clone(), ctrl_typevar); let entry = visible_values.entry(key); use std::collections::hash_map::Entry::*;