caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jonathan Kimmitt <jonathan@kimmitt.co.uk>
To: caml-list@yquem.inria.fr
Subject: Re: optimize div to right shift (NOT!)
Date: Mon, 13 Dec 2010 12:33:33 +0000	[thread overview]
Message-ID: <BB6FC70B-2E26-4BD2-8335-FB31E90FA377@kimmitt.co.uk> (raw)
In-Reply-To: <20101212172643.3EF80BC5D@yquem.inria.fr>


> A C compiler would optimize this to a right shift. Changing that to 'Int64.shift_right n 1' speeds
> up the code.

Sorry to be a pedant, but this is not correct. The optimisation is only possible when the arguments
are unsigned integers which I don't think is specifiable when working in OCAML

# Int64.shift_right (-2L) 1;;
- : int64 = -1L (So far, so good)
# Int64.div (-1L) 2L;;
- : int64 = 0L (Good)
# Int64.shift_right (-1L) 1;;
- : int64 = -1L (Duh)



       reply	other threads:[~2010-12-13 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20101212172643.3EF80BC5D@yquem.inria.fr>
2010-12-13 12:33 ` Jonathan Kimmitt [this message]
2010-12-13 12:58   ` [Caml-list] " Török Edwin
2010-12-13 13:03     ` Benedikt Meurer
2010-12-13 20:13     ` Jon Harrop

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=BB6FC70B-2E26-4BD2-8335-FB31E90FA377@kimmitt.co.uk \
    --to=jonathan@kimmitt.co.uk \
    --cc=caml-list@yquem.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).