From: Xavier Leroy <xavier.leroy@inria.fr>
To: Pascal Zimmer <Pascal.Zimmer@sophia.inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Optimizing false polymorphic local functions
Date: Thu, 13 Feb 2003 15:50:38 +0100 [thread overview]
Message-ID: <20030213155038.A20336@pauillac.inria.fr> (raw)
In-Reply-To: <3E4932B3.22A041D1@sophia.inria.fr>; from Pascal.Zimmer@sophia.inria.fr on Tue, Feb 11, 2003 at 06:28:19PM +0100
> The other day, I ran into a significant speedup improvement.
> [...]
> Now consider the slightly different version where "loop" is forced into
> a monomorphic function:
> [...]
> On my computer in native code, the speedup is really significant: more
> than 6 times faster (OK this example was built on purpose...). The
> reason is that in the first case, the operator <= is replaced by a call
> to the internal polymorphic compare_val function, whereas is the second
> case a direct comparison between integers is performed.
>
> I suspect there are other cases in which the compiler can produce a
> better code when it knows more precisely the types involved.
Yes: besides comparisons, array and bigarray accesses can be compiled
more efficiently if the exact types of the data are known statically.
> So my question is: would it be possible to help him in this way by
> enforcing the type checker to infer a monomorphic type in such
> situations ? By "such situations", I mean: local polymorphic
> functions that are used in exactly one monomorphic setting
> afterwards. Of course, this is not desirable for global functions,
> since it may break the calculus; but for local functions, it should
> be of no harm since we know all the places where they are used, and
> it would not change the type of the wrapper, thus being transparent
> for the user...
> Any comment ?
The following paper formalizes exactly this idea, and gives a type
inference algorithm that avoids unecessary polymorphism like you suggest:
http://citeseer.nj.nec.com/bjorner94minimal.html
- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2003-02-13 14:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-11 17:28 Pascal Zimmer
2003-02-13 14:50 ` Xavier Leroy [this message]
2003-02-14 17:54 ` Pascal Zimmer
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=20030213155038.A20336@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=Pascal.Zimmer@sophia.inria.fr \
--cc=caml-list@inria.fr \
/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