diff options
-rw-r--r-- | asmcomp/i386/emit.mlp | 2 | ||||
-rw-r--r-- | asmcomp/m68k/emit.mlp | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/asmcomp/i386/emit.mlp b/asmcomp/i386/emit.mlp index eb16e3f39..fe4eac8db 100644 --- a/asmcomp/i386/emit.mlp +++ b/asmcomp/i386/emit.mlp @@ -434,6 +434,8 @@ let emit_instr i = ` incl {emit_reg i.res.(0)}\n` | Lop(Iintop_imm(Iadd, -1) | Iintop_imm(Isub, 1)) -> ` decl {emit_reg i.res.(0)}\n` + | Lop(Iintop_imm(Iadd, n)) when i.arg.(0).loc <> i.res.(0).loc -> + ` leal {emit_int n}({emit_reg i.arg.(0)}), {emit_reg i.res.(0)}\n` | Lop(Iintop_imm(Idiv, n)) -> let l = Misc.log2 n in let lbl = new_label() in diff --git a/asmcomp/m68k/emit.mlp b/asmcomp/m68k/emit.mlp index e92fa6a11..aaa7fb5eb 100644 --- a/asmcomp/m68k/emit.mlp +++ b/asmcomp/m68k/emit.mlp @@ -439,8 +439,11 @@ let emit_instr i = ` subql #{emit_int(-n)}, {emit_reg dest}\n`; set_cc i.res.(0) | _ -> - ` addl #{emit_int n}, {emit_reg dest}\n`; - set_cc i.res.(0) + if i.arg.(0).loc = i.res.(0).loc then begin + ` addl #{emit_int n}, {emit_reg dest}\n`; + set_cc i.res.(0) + end else + ` lea {emit_reg i.arg.(0)}@({emit_int n}), {emit_reg i.res.(0)}\n` end | Lop(Iintop_imm(Isub, n)) -> let dest = i.res.(0) in |