caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: "Richard W.M. Jones" <rich@annexia.org>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] ppc64le behaviour of Int64.min_int ÷ -1
Date: Mon, 29 Jun 2015 20:00:30 +0200	[thread overview]
Message-ID: <CAH=h3gFP-7h4nKojCNGcwZ+Jy=UrUwjeRx5RmmU5cqY78-0=Yw@mail.gmail.com> (raw)
In-Reply-To: <20150629175026.GE31462@annexia.org>

[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]

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
>
>

[-- Attachment #2: Type: text/html, Size: 2806 bytes --]

  reply	other threads:[~2015-06-29 18:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-29 17:50 Richard W.M. Jones
2015-06-29 18:00 ` Xavier Leroy [this message]
2015-06-29 18:08   ` Richard W.M. Jones
2015-06-29 18:15     ` Richard W.M. Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH=h3gFP-7h4nKojCNGcwZ+Jy=UrUwjeRx5RmmU5cqY78-0=Yw@mail.gmail.com' \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).