@@ -215,15 +215,29 @@ module Generate (Target : Target_sig.S) = struct
215215 (transl_prim_arg ctx ~typ: (Int Normalized ) x)
216216 (transl_prim_arg ctx ~typ: (Int Normalized ) y)
217217
218- let translate_int_equality ctx op op' x y =
218+ let translate_int_equality ctx ~ negate x y =
219219 match get_type ctx x, get_type ctx y with
220220 | (Int Normalized as typ ), Int Normalized ->
221- op (transl_prim_arg ctx ~typ x) (transl_prim_arg ctx ~typ y)
221+ (if negate then Arith. ( <> ) else Arith. ( = ))
222+ (transl_prim_arg ctx ~typ x)
223+ (transl_prim_arg ctx ~typ y)
222224 | Int (Normalized | Unnormalized ), Int (Normalized | Unnormalized ) ->
223- op
225+ ( if negate then Arith. ( <> ) else Arith. ( = ))
224226 Arith. (transl_prim_arg ctx ~typ: (Int Unnormalized ) x lsl const 1l )
225227 Arith. (transl_prim_arg ctx ~typ: (Int Unnormalized ) y lsl const 1l )
226- | _ -> op' (transl_prim_arg ctx ~typ: Top x) (transl_prim_arg ctx ~typ: Top y)
228+ | Top , Top ->
229+ (if negate then Value. phys_neq else Value. phys_eq)
230+ ~relaxed: true
231+ (transl_prim_arg ctx ~typ: Top x)
232+ (transl_prim_arg ctx ~typ: Top y)
233+ | Int (Normalized | Unnormalized ), (Int Ref | Top | Bot | Number _ | Tuple _)
234+ | (Int Ref | Top | Bot | Number _ | Tuple _), Int (Normalized | Unnormalized )
235+ | ( (Int Ref | Top | Bot | Number _ | Tuple _)
236+ , (Int Ref | Top | Bot | Number _ | Tuple _ ) ) ->
237+ (if negate then Value. phys_neq else Value. phys_eq)
238+ ~relaxed: false
239+ (transl_prim_arg ctx ~typ: Top x)
240+ (transl_prim_arg ctx ~typ: Top y)
227241
228242 let internal_primitives =
229243 let h = String.Hashtbl. create 128 in
@@ -864,8 +878,8 @@ module Generate (Target : Target_sig.S) = struct
864878 | Prim (Lt, [ x ; y ]) -> translate_int_comparison ctx Arith. ( < ) x y
865879 | Prim (Le, [ x ; y ]) -> translate_int_comparison ctx Arith. ( < = ) x y
866880 | Prim (Ult, [ x ; y ]) -> translate_int_comparison ctx Arith. ult x y
867- | Prim (Eq, [ x ; y ]) -> translate_int_equality ctx Arith. ( = ) Value. eq x y
868- | Prim (Neq, [ x ; y ]) -> translate_int_equality ctx Arith. ( <> ) Value. neq x y
881+ | Prim (Eq, [ x ; y ]) -> translate_int_equality ctx ~negate: false x y
882+ | Prim (Neq, [ x ; y ]) -> translate_int_equality ctx ~negate: true x y
869883 | Prim (Array_get, [ x ; y ]) ->
870884 Memory. array_get
871885 (transl_prim_arg ctx x)
0 commit comments