Skip to content

Commit c34dcbc

Browse files
committed
CR
1 parent a3419ab commit c34dcbc

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

compiler/lib/code.ml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,33 @@ module Constant = struct
349349
| NativeInt _, (Int _ | Int32 _)
350350
| (Int32 _ | NativeInt _), Float _
351351
| Float _, (Int32 _ | NativeInt _) -> None
352+
353+
let rec equal c c' =
354+
match c, c' with
355+
| String s, String s' -> String.equal s s'
356+
| NativeString s, NativeString s' -> Native_string.equal s s'
357+
| Float f, Float f' -> Float.bitwise_equal f f'
358+
| Float_array a, Float_array a' -> Array.equal Float.bitwise_equal a a'
359+
| Int i, Int i' -> Targetint.equal i i'
360+
| Int32 i, Int32 i' | NativeInt i, NativeInt i' -> Int32.equal i i'
361+
| Int64 i, Int64 i' -> Int64.equal i i'
362+
| Tuple (t, a, kind), Tuple (t', a', kind') -> (
363+
t = t'
364+
&& Array.equal equal a a'
365+
&&
366+
match kind, kind' with
367+
| Array, Array | NotArray, NotArray | Unknown, Unknown -> true
368+
| (Array | NotArray | Unknown), _ -> false)
369+
| ( ( String _
370+
| NativeString _
371+
| Float _
372+
| Float_array _
373+
| Int _
374+
| Int32 _
375+
| NativeInt _
376+
| Int64 _
377+
| Tuple _ )
378+
, _ ) -> false
352379
end
353380

354381
type loc =
@@ -795,18 +822,15 @@ let eq p1 p2 =
795822
&& List.equal
796823
~eq:(fun i i' ->
797824
match i, i' with
798-
| Let (x, Constant (Float f)), Let (x', Constant (Float f')) ->
799-
Var.equal x x' && Float.bitwise_equal f f'
800-
| ( Let (x, Constant (Float_array a))
801-
, Let (x', Constant (Float_array a')) ) ->
802-
Var.equal x x' && Array.equal Float.bitwise_equal a a'
825+
| Let (x, Constant c), Let (x', Constant c') ->
826+
Var.equal x x' && Constant.equal c c'
803827
| Let (x, Prim (prim, args)), Let (x', Prim (prim', args')) ->
804828
Var.equal x x'
805829
&& Poly.equal prim prim'
806830
&& List.equal
807831
~eq:(fun a a' ->
808832
match a, a' with
809-
| Pc (Float f), Pc (Float f') -> Float.bitwise_equal f f'
833+
| Pc c, Pc c' -> Constant.equal c c'
810834
| _ -> Poly.equal a a')
811835
args
812836
args'

0 commit comments

Comments
 (0)