Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Frédéric Bour" <frederic.bour@lakaban.net>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: Nils Becker <nils.becker@bioquant.uni-heidelberg.de>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: Re: [Caml-list] Ocaml optimizer pitfalls & work-arounds
Date: Thu, 19 Jan 2017 14:26:02 +0100	[thread overview]
Message-ID: <88AFA979-41BD-4E93-BA6F-604D88427F2C@lakaban.net> (raw)
In-Reply-To: <CAPFanBFHoSwfJU=f6Dq-M_9f3ueYou2epPh=eCs0t8HtoHSMQQ@mail.gmail.com>

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

Le 19 janv. 2017 à 12:39, Gabriel Scherer <gabriel.scherer@gmail.com> a écrit :
> 
>> the min, max issues can be avoided without much trouble by using
>> specialized comparison, as provided in standard library extensions.
> 
> Note that min/max are already optimized from generic to specialized
> when the type information is known at type-checking time. (It used to
> be the case that only fully applied calls were optimized, this was
> improved by Frédéric Bour to extend to non-applied primitives in 4.03
> (eg. "let eq : int -> int -> _ = (=)"). That does not work when those
> functions are used inside a functor body at an abstract type (which is
> when we want inlining and specialization to interact better), but
> there neither do Float.equal or Int.compare.

Alas, min/max cannot benefit from this optimisation.

In Pervasives, they are defined as:

let min x y = if x <= y then x else y
let max x y = if x >= y then x else y

Specialization only happens for primitives, here it is a plain definition.
So no specialization unless the definitions are copied and annotated :(.

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

  reply	other threads:[~2017-01-19 13:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19  6:51 Mark Hayden
2017-01-19 11:20 ` Nils Becker
2017-01-19 11:39   ` Gabriel Scherer
2017-01-19 13:26     ` Frédéric Bour [this message]
2017-01-19 14:35   ` Alain Frisch
2017-01-19 15:35     ` Ivan Gotovchits
2017-01-19 17:02       ` Hezekiah M. Carty
2017-01-19 15:41     ` Gerd Stolpmann
2017-01-19 13:41 ` Yaron Minsky
2017-01-19 17:59   ` Mark Hayden
2017-01-19 22:30     ` Yaron Minsky
2017-01-22 20:06       ` Berke Durak
2017-01-23 16:33         ` David McClain
2017-01-21 14:39 ` [Caml-list] <DKIM> " Pierre Chambart
2017-01-19 14:32 [Caml-list] " Hongbo Zhang (BLOOMBERG/ 731 LEX)

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=88AFA979-41BD-4E93-BA6F-604D88427F2C@lakaban.net \
    --to=frederic.bour@lakaban.net \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@gmail.com \
    --cc=nils.becker@bioquant.uni-heidelberg.de \
    /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