From: Dmitry Bely <dmitry.bely@gmail.com>
To: Alain Frisch <alain.frisch@lexifi.com>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Int32 vs float unboxing
Date: Mon, 22 Aug 2011 12:33:59 +0400 [thread overview]
Message-ID: <CAMT7qiRv6K2xX7D3WXaxDPg5_pbmYUoD9twbxnH85i4nesxUUA@mail.gmail.com> (raw)
In-Reply-To: <4E520C27.3020205@lexifi.com>
On Mon, Aug 22, 2011 at 11:58 AM, Alain Frisch <alain.frisch@lexifi.com> wrote:
> On 08/22/2011 09:19 AM, Dmitry Bely wrote:
>>
>> In the code below "s" reference is unboxed in sum_float loop, but not
>> in sum_int32. Why?
>>
>> let sum_int32 v =
>> let s = ref 0l in
>> for i=0 to (Array.length v)-1 do
>> s := Int32.add !s (Array.unsafe_get v i)
>> done;
>> Int32.add !s Int32.zero
>>
>> let sum_float v =
>> let s = ref 0. in
>> for i=0 to (Array.length v)-1 do
>> s := !s +. (Array.unsafe_get v i)
>> done;
>> !s +. 0.
>
> A random guess: since adding Int32.zero is the identity (contrary to adding
> 0.), the compiler is clever enough to optimize away this useless operation;
> unfortunately, this optimization breaks the unboxing pass.
Probably no. If you replace
Int32.add !s Int32.zero
with
Int32.add !s Int32.one
s is still boxed. BTW, even zero addition is not optimized away.
- Dmitry Bely
next prev parent reply other threads:[~2011-08-22 8:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-22 7:19 Dmitry Bely
2011-08-22 7:58 ` Alain Frisch
2011-08-22 8:33 ` Dmitry Bely [this message]
2011-08-24 8:10 ` [Caml-list] " Dmitry Bely
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=CAMT7qiRv6K2xX7D3WXaxDPg5_pbmYUoD9twbxnH85i4nesxUUA@mail.gmail.com \
--to=dmitry.bely@gmail.com \
--cc=alain.frisch@lexifi.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