Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about optimizing

Author: Uri Blass

Date: 05:41:46 07/11/03

Go up one level in this thread


On July 11, 2003 at 08:04:48, Gerd Isenberg wrote:

>On July 10, 2003 at 23:04:04, Uri Blass wrote:
>
>>I have in movei cases when I have 2 lines like the following when s can be only
>>0 or 1 and 128 can be every power of 2 that is less than 2^16
>>
>>directsee[target]|=(128<<(s<<4));
>>directsee[target]&=~(128<<((1^s)<<4));
>>
>>My question is if there is a way to optimize it.
>>
>>There are also case when I know s and may have something like the following:
>>
>>directsee[target]|=64;
>>directsee[target]&=~(64<<16);
>>
>>I do not know if there is a way to do it faster(I expect a smart compiler to
>>optimize it by itself).
>>
>>Uri
>
>Hi Uri,
>
>directsee[target] |=(128<<(s<<4));
>
>assuming directsee is 32 bit array:
>
>s ==> {0,1}
>s << 4 ==> {0,16}
>0x00000080 << (s << 4) ==> {0x00000080, 0x00800000}
>
>what about a union of directsee with one 32 bit int and two short 16-bit ints
>and to write:
>
>directsee[target].short16[s] |= 128;
>
>Cheers,
>Gerd

I will try it

I understand that
directsee[target]&=~(128<<((1^s)<<4)) should be translated to
directsee[target].short16[1^s]&=~128;

The question is if the following is the fastest or I can do it in a faster way:

directsee[target].short16[s] |= 128;
directsee[target].short16[1^s]&=~128;


Uri



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.