Commit 1c69069c authored by qinsoon's avatar qinsoon

wont generate mov from tmp_a to tmp_a in intermediate block. No longer

put binop/move as tree child
parent e0dd25b3
Pipeline #1244 passed with stages
in 54 minutes and 2 seconds
...@@ -4485,7 +4485,12 @@ pub fn spill_rewrite( ...@@ -4485,7 +4485,12 @@ pub fn spill_rewrite(
.clone_value(); .clone_value();
// maintain mapping // maintain mapping
trace!("reg {} used in Inst{} is replaced as {}", val_reg, i, temp); trace!(
"reg {} used in Inst{} is replaced as {}",
val_reg.id(),
i,
temp
);
spilled_scratch_temps.insert(temp.id(), reg); spilled_scratch_temps.insert(temp.id(), reg);
// generate a load // generate a load
...@@ -4542,7 +4547,7 @@ pub fn spill_rewrite( ...@@ -4542,7 +4547,7 @@ pub fn spill_rewrite(
}; };
trace!( trace!(
"reg {} defined in Inst{} is replaced as {}", "reg {} defined in Inst{} is replaced as {}",
val_reg, val_reg.id(),
i, i,
temp temp
); );
......
...@@ -243,13 +243,13 @@ impl InterferenceGraph { ...@@ -243,13 +243,13 @@ impl InterferenceGraph {
self.adj_list.get_mut(&u).unwrap().insert(v); self.adj_list.get_mut(&u).unwrap().insert(v);
let degree = self.get_degree_of(u); let degree = self.get_degree_of(u);
self.set_degree_of(u, degree + 1); self.set_degree_of(u, degree + 1);
trace!("increase degree of {} to {}", u, degree + 1); trace!(" increase degree of {} to {}", u, degree + 1);
} }
if !is_precolored(v) { if !is_precolored(v) {
self.adj_list.get_mut(&v).unwrap().insert(u); self.adj_list.get_mut(&v).unwrap().insert(u);
let degree = self.get_degree_of(v); let degree = self.get_degree_of(v);
self.set_degree_of(v, degree + 1); self.set_degree_of(v, degree + 1);
trace!("increase degree of {} to {}", v, degree + 1); trace!(" increase degree of {} to {}", v, degree + 1);
} }
} }
} }
...@@ -310,7 +310,7 @@ impl InterferenceGraph { ...@@ -310,7 +310,7 @@ impl InterferenceGraph {
} }
pub fn set_degree_of(&mut self, reg: MuID, degree: usize) { pub fn set_degree_of(&mut self, reg: MuID, degree: usize) {
debug!("DEGREE({}) SET TO {}", reg, degree); trace!(" set degree({}) = {}", reg, degree);
self.degree.insert(reg, degree); self.degree.insert(reg, degree);
} }
......
...@@ -54,6 +54,7 @@ impl<'vm> Compiler<'vm> { ...@@ -54,6 +54,7 @@ impl<'vm> Compiler<'vm> {
/// compiles a certain function version /// compiles a certain function version
pub fn compile(&self, func: &mut MuFunctionVersion) { pub fn compile(&self, func: &mut MuFunctionVersion) {
info!(""); info!("");
info!("compilation_start {}", func.id());
info!("Start compiling {}", func); info!("Start compiling {}", func);
info!(""); info!("");
debug!("{:?}", func); debug!("{:?}", func);
...@@ -78,6 +79,7 @@ impl<'vm> Compiler<'vm> { ...@@ -78,6 +79,7 @@ impl<'vm> Compiler<'vm> {
// build exception table for this function // build exception table for this function
unimplemented!() unimplemented!()
} }
info!("compilation_end {}", func.id());
} }
} }
......
...@@ -324,6 +324,10 @@ impl CompilerPass for GenMovPhi { ...@@ -324,6 +324,10 @@ impl CompilerPass for GenMovPhi {
// move every from_arg to target_arg // move every from_arg to target_arg
let mut i = 0; let mut i = 0;
for arg in block_info.from_args.iter() { for arg in block_info.from_args.iter() {
let ref target_arg = target_args[i];
// when a block branches to itself, it is possible that
// arg is the same as target_arg
if arg.as_value() != target_arg {
let m = func.new_inst(Instruction { let m = func.new_inst(Instruction {
hdr: MuEntityHeader::unnamed(vm.next_id()), hdr: MuEntityHeader::unnamed(vm.next_id()),
value: Some(vec![target_args[i].clone()]), value: Some(vec![target_args[i].clone()]),
...@@ -332,6 +336,7 @@ impl CompilerPass for GenMovPhi { ...@@ -332,6 +336,7 @@ impl CompilerPass for GenMovPhi {
}); });
vec.push(m); vec.push(m);
}
i += 1; i += 1;
} }
......
...@@ -89,8 +89,8 @@ fn is_suitable_child(inst: &Instruction) -> bool { ...@@ -89,8 +89,8 @@ fn is_suitable_child(inst: &Instruction) -> bool {
AtomicRMW { .. } | AtomicRMW { .. } |
Store { .. } => false, Store { .. } => false,
BinOp(_, _, _) | BinOp(_, _, _) | BinOpWithStatus(_, _, _, _) | CommonInst_GetThreadLocal | Move(_) => false,
BinOpWithStatus(_, _, _, _) |
CmpOp(_, _, _) | CmpOp(_, _, _) |
ConvOp { .. } | ConvOp { .. } |
Load { .. } | Load { .. } |
...@@ -98,9 +98,7 @@ fn is_suitable_child(inst: &Instruction) -> bool { ...@@ -98,9 +98,7 @@ fn is_suitable_child(inst: &Instruction) -> bool {
GetFieldIRef { .. } | GetFieldIRef { .. } |
GetElementIRef { .. } | GetElementIRef { .. } |
ShiftIRef { .. } | ShiftIRef { .. } |
GetVarPartIRef { .. } | GetVarPartIRef { .. } => true
CommonInst_GetThreadLocal |
Move(_) => true
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment