Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Saved Another Cycle -- Woohoo!

Author: Robert Hyatt

Date: 06:34:36 01/06/03

Go up one level in this thread


On January 06, 2003 at 02:19:34, Dieter Buerssner wrote:

>On January 05, 2003 at 22:52:06, Robert Hyatt wrote:
>
>>If you like cute code, here is Eugene's FirstOne() function for
>>Crafty.  It is cute, but has one drawback in that it can not be inlined
>>due to the addressing computations he does which means that the value being
>>checked for FirstOne() has to be in memory...
>
>Did you try the "m" constraint for Gcc inline assembly? Perhaps, together with
>using a local volatile variable:
>
>__inline__ int FirstOne(Bitboard b)
>{
>  volatile Bitboard lb = b;
>  int result;   __asm__(" ... " : "=r&" (result) /* ... */ : "m" (lb));
>  return result;
>}
>
>Regards,
>Dieter


No.  because the _address_ is important.  If you look at his code, he uses a
cute trick to figure out which half of the 64 bit thing to work on, and then
he uses that address later to adjust things correctly...

I didn't see how the =m constraint would work although it is certainly
possible.  But then the problem is that the value _might_ be in a pair
of registers at the point where the function is called, and they would
have to be stored to memory before the inline function could be executed.

Without the address arithmetic, the version I wrote is happy with the
value anywhere, as it requests that it be sucked into registers if it isn't
already there...  a better chance for optimization, basically.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.