Hi Richard,

You need to put "let division_crashes_on_overflow = true" in asmcomp/$ARCH/arch.ml, just like in asmcomp/power/arch.ml.  The name of the variable is perhaps counterintuitive but means "min_int / -1 doesn't do what we want, so add tests (in cmmgen) for this case".

- Xavier


2015-06-29 19:50 GMT+02:00 Richard W.M. Jones <rich@annexia.org>:
Downstream bug: https://bugzilla.redhat.com/show_bug.cgi?id=1236615

OCaml expects Int64.min_int ÷ -1 to overflow and wrap around
(resulting in Int64.min_int).  There is also a test case in the test
suite for this.  See this previously fixed bug:

http://caml.inria.fr/mantis/view.php?id=5513

The compiler seems to cater for the case where an overflow in the
division throws an exception.

Unfortunately ppc64le does neither of these things: On ppc64le the
result of the computation is explicitly undefined, it sets a flag bit
(OV), but it doesn't throw an exception.

[See page 76 of
https://www.power.org/wp-content/uploads/2013/05/PowerISA_V2.07_PUBLIC.pdf ]

I wonder if there is a way to tell the compiler about this?  I could
add a conditional branch, but that would make the expansion of every
Int64.div and Int64.rem quite large (but maybe that doesn't matter as
these functions are going to be slow anyway?)

Suggestions welcome ...

Rich.

--
Richard Jones
Red Hat

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs