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 JAA23227; Fri, 25 Oct 2002 09:26:42 +0200 (MET DST) 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 JAA23934 for caml-list@pauillac.inria.fr; Fri, 25 Oct 2002 09:26:42 +0200 (MET DST) 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 FAA20364 for ; Fri, 25 Oct 2002 05:16:11 +0200 (MET DST) Received: from star2.baremetal.com (star2.baremetal.com [216.86.113.248]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g9P3G9D00505 for ; Fri, 25 Oct 2002 05:16:10 +0200 (MET DST) Received: from blackfen.com (akiv48cdy59dc.bc.hsia.telus.net [216.232.81.110]) by star2.baremetal.com (8.12.4/8.12.4) with ESMTP id g9P3NSep014677 for ; Thu, 24 Oct 2002 20:23:28 -0700 Date: Thu, 24 Oct 2002 20:13:06 -0700 Subject: Re: [Caml-list] Floating point boxing again Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v546) From: Quetzalcoatl Bradley To: caml-list@inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: X-Mailer: Apple Mail (2.546) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Very interesting! On PowerPC, the code is also very different, and the one with the spurious addition is MUCH faster. (factor of about 4.5 times faster) version A keeps the reference up to date in memory for every iteration of the loop. version B just accumulates the value in a register, updating the reference at the end of the loop. Obviously, all the updating of the reference is a lot of memory accessing. I'm not familiar with the compiler internals but I can imagine how the logic might look here. Perhaps the code generator looks at the reference, and sees that in case A, the next use after the loop is boxed (to return it), while in version B, it is unboxed (to add to it), and concludes that in case A it will keep it boxed the whole time, unboxed in case B. Can anyone describe why the compiler will decide to keep the value boxed/unboxed in the loop? Thanks, Quetzalcoatl Bradley qbradley@blackfen.com On Thursday, October 24, 2002, at 01:37 AM, malc wrote: > let a n = > let x = ref 1.0 in > for i = 1 to n do > x := !x +. 1.0; > done; > !x > > let b n = > let x = ref 1.0 in > for i = 1 to n do > x := !x +. 1.0; > done; > !x +. 0.0 > > The code produced for a and b respectively differ greatly, even the > inner > loops. Can someone from Caml team clarify the issue? > > P.S. Native code obviously. > > -- > mailto:malc@pulsesoft.com > > ------------------- > 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 > ------------------- 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