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 TAA25578; Mon, 27 Oct 2003 19:50:37 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA24659 for ; Mon, 27 Oct 2003 19:50:36 +0100 (MET) Received: from ms-smtp-01-eri0.ohiordc.rr.com (ms-smtp-01-smtplb.ohiordc.rr.com [65.24.5.135]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h9RIoZ106400 for ; Mon, 27 Oct 2003 19:50:35 +0100 (MET) Received: from vilya (cpe-024-033-201-104.columbus.rr.com [24.33.201.104]) by ms-smtp-01-eri0.ohiordc.rr.com (8.12.10/8.12.7) with ESMTP id h9RIoLxC022002; Mon, 27 Oct 2003 13:50:24 -0500 (EST) Received: from andrewl by vilya with local (Exim 3.36 #1 (Debian)) id 1AECRZ-0000TO-00; Mon, 27 Oct 2003 13:50:21 -0500 Date: Mon, 27 Oct 2003 13:50:21 -0500 From: Andrew Lenharth To: William Chesters Cc: caml-list@inria.fr Subject: Re: [Caml-list] partial eval question Message-ID: <20031027185021.GA1793@vilya.homelinux.net> References: <004a01c39c2b$819db8f0$1fcf2952@Archimedes> <20031027081453.37b9f6ee.Damien.Pous@ens-lyon.fr> <16285.15401.421786.814601@beertje.william.bogus> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16285.15401.421786.814601@beertje.william.bogus> User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 chesters:01 keywork:01 compiler:01 int:01 int:01 explicit:03 wrote:03 inline:03 inline:03 oct:03 partial:03 william:05 0000,:05 requires:06 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, Oct 27, 2003 at 03:39:21PM +0000, William Chesters wrote: > And that's an improvement over > > double pow(double x, int n) { > double it = 1; > while (--n >= 0) it *= x; > return it; > } > > double pow3(double x, int n) { > return pow(x, 3); > } > > in what way exactly? (If it doesn't work for you, try > -funroll-all-loops.) And that's an improvement over template inline double pow (double x) { return x * pow(x); } template<> inline double pow<0> (double x) { return 1.0; } in what way exactly? (If it doesn't work for you, try -O2) :) The C example relies on a fairly smart compiler to do interprocedual analysis. The C++ example only requires the inline keywork be honored, and you don't need explicit pow3 pow2, you have pow<3> pow<2> pow. Gives a bit more control over code generation. Andrew ------------------- 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