Skip to content

Commit

Permalink
Amd64 emit tweaks (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
xclerc authored and poechsel committed Jun 25, 2021
1 parent a11f6fb commit 2509c40
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backend/amd64/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ let emit_instr fallthrough i =
let lbl = bound_error_label i.dbg in
I.cmp (int n) (arg i 0);
I.jbe (label lbl)
| Lop(Iintop_imm (Iand, n)) when n >= 0 && n <= 0xFFFF_FFFF && Reg.is_reg i.res.(0) ->
I.and_ (int n) (res32 i 0)
| Lop(Iintop Ixor) when i.arg.(1).loc = i.res.(0).loc && Reg.is_reg i.res.(0) ->
I.xor (res32 i 0) (res32 i 0)
| Lop(Iintop(Idiv | Imod)) ->
I.cqo ();
I.idiv (arg i 1)
Expand All @@ -802,9 +806,9 @@ let emit_instr fallthrough i =
instr_for_intop op (arg i 1) (res i 0)
| Lop(Iintop_imm(Iadd, n)) when i.arg.(0).loc <> i.res.(0).loc ->
I.lea (mem64 NONE n (arg64 i 0)) (res i 0)
| Lop(Iintop_imm(Iadd, 1) | Iintop_imm(Isub, -1)) ->
| Lop(Iintop_imm(Iadd, 1) | Iintop_imm(Isub, -1)) when not !fastcode_flag ->
I.inc (res i 0)
| Lop(Iintop_imm(Iadd, -1) | Iintop_imm(Isub, 1)) ->
| Lop(Iintop_imm(Iadd, -1) | Iintop_imm(Isub, 1)) when not !fastcode_flag ->
I.dec (res i 0)
| Lop(Iintop_imm(op, n)) ->
(* We have i.arg.(0) = i.res.(0) *)
Expand Down

0 comments on commit 2509c40

Please sign in to comment.