comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: sub-optimal code for packed boolean arrays -- bug or inherent limitation
Date: Mon, 9 Jul 2007 21:06:34 -0500
Date: 2007-07-09T21:06:34-05:00	[thread overview]
Message-ID: <f6upf2$rhr$1@jacob-sparre.dk> (raw)
In-Reply-To: 1183486662.806585.71680@q69g2000hsb.googlegroups.com

"Alinabi" <alexander.the.average@gmail.com> wrote in message
news:1183486662.806585.71680@q69g2000hsb.googlegroups.com...
> One more thing: some inline assembly is unavoidable. There are two
> other bitboard operations that are required: First_One(Bitboard_T)
> returns Natural and Last_One(Bitboard_T) returns Natural; They return
> the position of the least significant and most significant set bit
> respectively. On x86 processors you can do this with one instruction
> BSF (bit scan forward) and BSR (bit scan reverse), and you cannot
> expect a compiler to generate them.

There's a reason for that: Intel recommended to compiler writers to not use
"complex" instructions, as sets of simple instructions are often supposed to
be faster. The "complex" instructions were implemented essentially as
"macros" of simple instructions. (This is information is somewhat old, so it
may vary on the most recent processors.)

My point is that it might not actually be faster to use those instructions
than to use a loop of your own design (and there is a small chance that
they'd be slower). As suggested elsewhere, you need to test that in a
suitable benchmark. The number of instructions has had no real bearing on
the execution time since the 486 came out (and indeed, given that some
instructions are much slower than others, it never had much bearing on
Intel's x86 processors).

                                    Randy.





  reply	other threads:[~2007-07-10  2:06 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-02 19:34 sub-optimal code for packed boolean arrays -- bug or inherent limitation Alinabi
2007-07-02 20:08 ` Ludovic Brenta
2007-07-03  1:01 ` Jeffrey R. Carter
2007-07-03  7:22   ` Harald Korneliussen
2007-07-03  8:37     ` Georg Bauhaus
2007-07-03  7:59 ` gautier_niouzes
2007-07-03  9:25 ` Stefan Lucks
2007-07-03 12:40   ` Stefan Lucks
2007-07-03 15:42 ` Adam Beneschan
2007-07-03 18:04 ` Alinabi
2007-07-03 18:09   ` Alinabi
2007-07-03 18:17     ` Alinabi
2007-07-10  2:06       ` Randy Brukardt [this message]
2007-07-03 18:36   ` Jeffrey R. Carter
2007-07-03 19:42     ` Alinabi
2007-07-04  1:12       ` Jeffrey R. Carter
2007-07-04 10:15         ` Jeffrey Creem
2007-07-04 18:28           ` Jeffrey R. Carter
2007-07-04  3:22       ` Steve
2007-07-04  6:31         ` Harald Korneliussen
2007-07-08 22:53     ` Robert A Duff
2007-07-09  6:09       ` tmoran
2007-07-04  9:00   ` Jean-Pierre Rosen
2007-07-04 18:27     ` tmoran
2007-07-04 19:16       ` Pascal Obry
2007-07-05  1:45         ` tmoran
2007-07-05  4:53       ` Jeffrey R. Carter
2007-07-04 18:51     ` tmoran
2007-07-08 22:58 ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox