* [Caml-list] inlining of functions
@ 2001-12-16 15:30 Markus Mottl
0 siblings, 0 replies; only message in thread
From: Markus Mottl @ 2001-12-16 15:30 UTC (permalink / raw)
To: OCAML
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-12-17 17:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-16 15:30 [Caml-list] inlining of functions Markus Mottl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox