From de53ed7fb7d42a810f1f08f5585256fdc800e6da Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Mon, 30 Jun 2003 11:29:26 +0000 Subject: [PATCH] Bugs dans intop_imm(Idiv | Imod) git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5635 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- asmcomp/amd64/emit.mlp | 4 ++-- asmcomp/amd64/selection.ml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp index 7ffb50734..ea6a642f2 100644 --- a/asmcomp/amd64/emit.mlp +++ b/asmcomp/amd64/emit.mlp @@ -436,7 +436,7 @@ let emit_instr fallthrough i = (* Note: i.arg.(0) = i.res.(0) = rdx (cf. selection.ml) *) let l = Misc.log2 n in ` movq {emit_reg i.arg.(0)}, %rax\n`; - ` addq {emit_int(n-1)}, {emit_reg i.arg.(0)}\n`; + ` addq ${emit_int(n-1)}, {emit_reg i.arg.(0)}\n`; ` testq %rax, %rax\n`; ` cmovns %rax, {emit_reg i.arg.(0)}\n`; ` sarq ${emit_int l}, {emit_reg i.res.(0)}\n` @@ -447,7 +447,7 @@ let emit_instr fallthrough i = ` testq %rax, %rax\n`; ` leaq {emit_int(n-1)}(%rax), %rax\n`; ` cmovns {emit_reg i.arg.(0)}, %rax\n`; - ` andq ${emit_int (n-1)}, %rax\n`; + ` andq ${emit_int (-n)}, %rax\n`; ` subq %rax, {emit_reg i.res.(0)}\n` | Lop(Iintop_imm(op, n)) -> (* We have i.arg.(0) = i.res.(0) *) diff --git a/asmcomp/amd64/selection.ml b/asmcomp/amd64/selection.ml index 31aed0b5f..acd79f141 100644 --- a/asmcomp/amd64/selection.ml +++ b/asmcomp/amd64/selection.ml @@ -87,7 +87,7 @@ let pseudoregs_for_operation op arg res = Iintop(Iadd|Isub|Imul|Iand|Ior|Ixor) | Iaddf|Isubf|Imulf|Idivf -> ([|res.(0); arg.(1)|], res) (* One-address unary operations: arg.(0) and res.(0) must be the same *) - | Iintop_imm((Iadd|Isub|Imul|Idiv|Iand|Ior|Ixor|Ilsl|Ilsr|Iasr), _) + | Iintop_imm((Iadd|Isub|Imul|Iand|Ior|Ixor|Ilsl|Ilsr|Iasr), _) | Iabsf | Inegf -> (res, res) | Ispecific(Ifloatarithmem(_,_)) -> @@ -104,9 +104,9 @@ let pseudoregs_for_operation op arg res = ([| rax; rcx |], [| rax |]) | Iintop(Imod) -> ([| rax; rcx |], [| rdx |]) - (* For mod with immediate operand, arg must not be in rax. + (* For div and mod with immediate operand, arg must not be in rax. Keep it simple, force it in rdx. *) - | Iintop_imm(Imod, _) -> + | Iintop_imm((Idiv|Imod), _) -> ([| rdx |], [| rdx |]) (* Other instructions are regular *) | _ -> raise Use_default