From: Markus Mottl <markus@oefai.at>
To: OCAML <caml-list@inria.fr>
Subject: [Caml-list] inlining of functions
Date: Sun, 16 Dec 2001 16:30:24 +0100 [thread overview]
Message-ID: <20011216163024.C7562@mail4.ai.univie.ac.at> (raw)
Hello,
I would like to know why OCaml does not produce the same machine code for:
let f x =
let g n = x + n in
g 1, g 2
and:
let f x =
x + 1, x + 2
OCaml obviously performs some inlining, but otherwise produces more
redundant code in the first example. The reason why I ask is that it
often happens that I want to factor out computations that are shared
between different case-arms like in:
let f x =
let g y = ... h x y ... in
match foo with
| A -> g n
| B -> g m
It may degrade performance in tight loops quite visibly if there is
extra-code to execute. One would have to use copy&paste to prevent this,
which is not really that elegant.
Regards,
Markus Mottl
P.S.: Congratulations to the whole OCaml-team for the recent release
of OCaml-3.04! You should add some bugs from time to time so
that people do not get bored marvelling about its unvaryingly
superb quality! ;)
--
Markus Mottl markus@oefai.at
Austrian Research Institute
for Artificial Intelligence http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
reply other threads:[~2001-12-17 17:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20011216163024.C7562@mail4.ai.univie.ac.at \
--to=markus@oefai.at \
--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