Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/asmcomp/cmmgen.ml b/asmcomp/cmmgen.ml
- index 1f640b9..3bd65a5 100644
- --- a/asmcomp/cmmgen.ml
- +++ b/asmcomp/cmmgen.ml
- @@ -349,9 +349,9 @@ let mod_int c1 c2 dbg =
- (c1, Cconst_int 0) ->
- Csequence(c1, Cop(Craise (Raise_regular, dbg),
- [Cconst_symbol "caml_exn_Division_by_zero"]))
- - | (c1, Cconst_int 1) ->
- - c1
- - | (Cconst_int(0 | 1) as c1, c2) ->
- + | (c1, Cconst_int (1 | (-1))) ->
- + Csequence(c1, Cconst_int 0)
- + | (Cconst_int(0 | 1 | (-1)) as c1, c2) ->
- Csequence(c2, c1)
- | (Cconst_int n1, Cconst_int n2) ->
- Cconst_int (n1 mod n2)
- diff --git a/testsuite/tests/basic/divint.ml b/testsuite/tests/basic/divint.ml
- index 52d14b9..fea3263 100644
- --- a/testsuite/tests/basic/divint.ml
- +++ b/testsuite/tests/basic/divint.ml
- @@ -74,6 +74,7 @@ let do_test divisor (df: nativeint -> nativeint) (mf: nativeint -> nativeint) =
- end
- let _ =
- + printf "1 int\n"; WithInt.do_test 1 (fun x -> x / 1)(fun x -> x mod 1);
- printf "2 int\n"; WithInt.do_test 2 (fun x -> x / 2)(fun x -> x mod 2);
- printf "3 int\n"; WithInt.do_test 3 (fun x -> x / 3)(fun x -> x mod 3);
- printf "4 int\n"; WithInt.do_test 4 (fun x -> x / 4)(fun x -> x mod 4);
- @@ -88,9 +89,11 @@ let _ =
- printf "55 int\n"; WithInt.do_test 55 (fun x -> x / 55)(fun x -> x mod 55);
- printf "125 int\n"; WithInt.do_test 125 (fun x -> x / 125)(fun x -> x mod 125);
- printf "625 int\n"; WithInt.do_test 625 (fun x -> x / 625)(fun x -> x mod 625);
- + printf "-1 int\n"; WithInt.do_test (-1) (fun x -> x / (-1))(fun x -> x mod (-1));
- printf "-2 int\n"; WithInt.do_test (-2) (fun x -> x / (-2))(fun x -> x mod (-2));
- printf "-3 int\n"; WithInt.do_test (-3) (fun x -> x / (-3))(fun x -> x mod (-3));
- + printf "1 nat\n"; WithNat.do_test 1 (fun x -> Nativeint.div x 1n)(fun x -> Nativeint.rem x 1n);
- printf "2 nat\n"; WithNat.do_test 2 (fun x -> Nativeint.div x 2n)(fun x -> Nativeint.rem x 2n);
- printf "3 nat\n"; WithNat.do_test 3 (fun x -> Nativeint.div x 3n)(fun x -> Nativeint.rem x 3n);
- printf "4 nat\n"; WithNat.do_test 4 (fun x -> Nativeint.div x 4n)(fun x -> Nativeint.rem x 4n);
- @@ -105,6 +108,7 @@ let _ =
- printf "55 nat\n"; WithNat.do_test 55 (fun x -> Nativeint.div x 55n)(fun x -> Nativeint.rem x 55n);
- printf "125 nat\n"; WithNat.do_test 125 (fun x -> Nativeint.div x 125n)(fun x -> Nativeint.rem x 125n);
- printf "625 nat\n"; WithNat.do_test 625 (fun x -> Nativeint.div x 625n)(fun x -> Nativeint.rem x 625n);
- + printf "-1 nat\n"; WithNat.do_test (-1) (fun x -> Nativeint.div x (-1n))(fun x -> Nativeint.rem x (-1n));
- printf "-2 nat\n"; WithNat.do_test (-2) (fun x -> Nativeint.div x (-2n))(fun x -> Nativeint.rem x (-2n));
- printf "-3 nat\n"; WithNat.do_test (-3) (fun x -> Nativeint.div x (-3n))(fun x -> Nativeint.rem x (-3n));
- diff --git a/testsuite/tests/basic/divint.reference b/testsuite/tests/basic/divint.reference
- index 4aa1e21..e9a6387 100644
- --- a/testsuite/tests/basic/divint.reference
- +++ b/testsuite/tests/basic/divint.reference
- @@ -1,3 +1,4 @@
- +1 int
- 2 int
- 3 int
- 4 int
- @@ -12,8 +13,10 @@
- 55 int
- 125 int
- 625 int
- +-1 int
- -2 int
- -3 int
- +1 nat
- 2 nat
- 3 nat
- 4 nat
- @@ -28,6 +31,7 @@
- 55 nat
- 125 nat
- 625 nat
- +-1 nat
- -2 nat
- -3 nat
- Test passed.
Add Comment
Please, Sign In to add comment