Misc refactorings when looking at the wasm code;

This commit is contained in:
Benjamin Bouvier
2018-07-12 19:59:06 +02:00
committed by Dan Gohman
parent c068721964
commit 03159a9200
4 changed files with 28 additions and 50 deletions

View File

@@ -271,7 +271,7 @@ impl DominatorTree {
//
// There are two ways of viewing the CFG as a graph:
//
// 1. Each EBB is a node, with outgoing edges for all the branches in the EBB>
// 1. Each EBB is a node, with outgoing edges for all the branches in the EBB.
// 2. Each basic block is a node, with outgoing edges for the single branch at the end of
// the BB. (An EBB is a linear sequence of basic blocks).
//

View File

@@ -517,25 +517,19 @@ fn simplify(pos: &mut FuncCursor, inst: Inst) {
..
} => {
// Fold away a redundant `bint`.
let maybe = {
let condition_def = {
let args = pos.func.dfg.inst_args(inst);
if let ValueDef::Result(def_inst, _) = pos.func.dfg.value_def(args[0]) {
if let InstructionData::Unary {
opcode: Opcode::Bint,
arg: bool_val,
} = pos.func.dfg[def_inst]
{
Some(bool_val)
} else {
None
}
} else {
None
}
pos.func.dfg.value_def(args[0])
};
if let Some(bool_val) = maybe {
let args = pos.func.dfg.inst_args_mut(inst);
args[0] = bool_val;
if let ValueDef::Result(def_inst, _) = condition_def {
if let InstructionData::Unary {
opcode: Opcode::Bint,
arg: bool_val,
} = pos.func.dfg[def_inst]
{
let args = pos.func.dfg.inst_args_mut(inst);
args[0] = bool_val;
}
}
}
_ => {}