Skip to content

Commit ce4ddd8

Browse files
committed
Compiler: comsume hints for boxed int comparison
1 parent 96556f8 commit ce4ddd8

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

compiler/lib/parse_bytecode.ml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,11 +1999,37 @@ and compile infos pc state (instrs : instr list) =
19991999
y
20002000
Var.print
20012001
z;
2002+
let prim, y, z =
2003+
match prim with
2004+
| "caml_equal"
2005+
| "caml_notequal"
2006+
| "caml_lessthan"
2007+
| "caml_greaterthan"
2008+
| "caml_lessequal"
2009+
| "caml_greaterequal" -> (
2010+
let prim_of_ext = function
2011+
| "caml_equal" -> Eq, y, z
2012+
| "caml_notequal" -> Neq, y, z
2013+
| "caml_lessthan" -> Lt, y, z
2014+
| "caml_lessequal" -> Le, y, z
2015+
| "caml_greaterequal" -> Le, z, y
2016+
| "caml_greaterthan" -> Lt, z, y
2017+
| _ -> assert false
2018+
in
2019+
match Hints.find infos.hints pc with
2020+
| [ Hints.Hint_int boxed ] -> (
2021+
match boxed with
2022+
| Pnativeint -> prim_of_ext prim
2023+
| Pint32 -> prim_of_ext prim
2024+
| Pint64 -> Extern prim, y, z)
2025+
| _ -> Extern prim, y, z)
2026+
| _ -> Extern prim, y, z
2027+
in
20022028
compile
20032029
infos
20042030
(pc + 2)
20052031
(State.pop 1 state)
2006-
(Let (x, Prim (Extern prim, [ Pv y; Pv z ])) :: instrs)
2032+
(Let (x, Prim (prim, [ Pv y; Pv z ])) :: instrs)
20072033
| C_CALL3 ->
20082034
let prim = primitive_name state (getu code (pc + 1)) in
20092035
let y = State.accu state in

0 commit comments

Comments
 (0)