From: Quetzalcoatl Bradley <qbradley@blackfen.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Floating point boxing again
Date: Thu, 24 Oct 2002 20:13:06 -0700 [thread overview]
Message-ID: <AEA112B2-E7C7-11D6-B580-0030657680C6@blackfen.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0210241233170.920-100000@home.oyster.ru>
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
prev parent reply other threads:[~2002-10-25 7:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-24 8:37 malc
2002-10-25 3:13 ` Quetzalcoatl Bradley [this message]
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=AEA112B2-E7C7-11D6-B580-0030657680C6@blackfen.com \
--to=qbradley@blackfen.com \
--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;
as well as URLs for NNTP newsgroup(s).