Commit 9a01d171 authored by qinsoon's avatar qinsoon

fix urem fail. peepopt should not remove 'mov %ah %al'

parent 62171d49
......@@ -10,4 +10,5 @@ Cargo.lock
.idea
*.pyc
*.o
*.dylib
mu-client-pypy
......@@ -162,6 +162,30 @@ pub fn get_alias_for_length(id: MuID, length: usize) -> P<Value> {
}
}
pub fn is_aliased(id1: MuID, id2: MuID) -> bool {
if get_color_for_precolroed(id1) == get_color_for_precolroed(id2) {
macro_rules! is_match {
($a1: expr, $a2: expr; $b: expr) => {
$a1 == $b.id() || $a2 == $b.id()
}
};
if is_match!(id1, id2; AH) {
return false;
} else if is_match!(id1, id2; BH) {
return false;
} else if is_match!(id1, id2; CH) {
return false;
} else if is_match!(id1, id2; DH) {
return false;
} else {
return true;
}
} else {
return false;
}
}
pub fn get_color_for_precolroed(id: MuID) -> MuID {
if id < FPR_ID_START {
match GPR_ALIAS_LOOKUP.get(&id) {
......
......@@ -25,7 +25,8 @@ pub mod x86_64;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::init_machine_regs_for_func;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::is_aliased;
#[cfg(target_arch = "x86_64")]
pub use compiler::backend::x86_64::get_color_for_precolroed;
#[cfg(target_arch = "x86_64")]
......
......@@ -44,9 +44,8 @@ impl PeepholeOptimization {
}
};
if backend::get_color_for_precolroed(src_machine_reg)
== backend::get_color_for_precolroed(dst_machine_reg) {
trace!("Redundant! removed");
if backend::is_aliased(src_machine_reg, dst_machine_reg) {
trace!("move between {} and {} is redundant! removed", src_machine_reg, dst_machine_reg);
// redundant, remove this move
cf.mc_mut().set_inst_nop(inst);
} else {
......
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