Skip to content

Commit

Permalink
Remove mov where arg and dst are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
voltrevo committed Jul 5, 2023
1 parent 7010296 commit 5b76267
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions valuescript_compiler/src/optimization/reduce_instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,21 @@ fn reduce(instr: Instruction) -> Option<Instruction> {
| Throw(..) | SetCatch(..) | UnsetCatch | ConstSubCall(..) | RequireMutableThis
| ThisSubCall(..) | Next(..) | Yield(..) | YieldStar(..) => Some(instr),

Mov(_, dst)
| OpPlus(_, _, dst)
Mov(arg, dst) => 'b: {
if dst.is_ignore() {
break 'b None;
}

if let Value::Register(arg) = arg {
if arg.name == dst.name {
break 'b None;
}
}

Some(instr)
}

OpPlus(_, _, dst)
| OpMinus(_, _, dst)
| OpMul(_, _, dst)
| OpDiv(_, _, dst)
Expand Down

0 comments on commit 5b76267

Please sign in to comment.