From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA22004; Mon, 17 Dec 2001 18:59:15 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA22282 for caml-list@pauillac.inria.fr; Mon, 17 Dec 2001 18:59:14 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA29289 for ; Sun, 16 Dec 2001 16:30:31 +0100 (MET) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id fBGFUUv04332 for ; Sun, 16 Dec 2001 16:30:30 +0100 (MET) Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.9.3/8.9.3/Debian 8.9.3-21) id QAA10051 for caml-list@inria.fr; Sun, 16 Dec 2001 16:30:24 +0100 Date: Sun, 16 Dec 2001 16:30:24 +0100 From: Markus Mottl To: OCAML Subject: [Caml-list] inlining of functions Message-ID: <20011216163024.C7562@mail4.ai.univie.ac.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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