Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Move generation question for the big boys

Author: Vincent Diepeveen

Date: 16:05:23 09/15/01

Go up one level in this thread


On September 15, 2001 at 17:53:14, Bruce Moreland wrote:

Yeah i was typing without head slowly. the idea is ok, but the
implementation sucked again.

I meant

   if ( a && b )

versus
   if ( (a|b) )

>On September 15, 2001 at 16:17:52, Vincent Diepeveen wrote:
>
>>Like if i check for 2 non-array/pointer entities for being zero:
>>
>>if( a & b )
>>  then do this and that;
>
>I don't know what you mean here, but is you probably don't mean to say "&".
>
>>to produce some crap assembly:
>>  CMP EAX,0
>>  JNZ LOOP
>>  CMP EDX,0
>>  JNZ LOOP1
>
>This seems to indicate that you meant "&&".
>
>>Now already people will complain: "you don't need special CMP for
>>2 different statements". Well they're right.
>>
>>In fact you don't need 2 compares even. All you need is something
>>primitive like:
>>
>>  ADD EAX,EDX
>>  CMP EAX,0
>>  JNZ LOOP1
>
>Or perhaps:
>
>    add eax, edx
>    jnz loop1
>
>But this isn't the same thing.  If "a" is 1, and "b" is -1, you get a failure
>here.  Okay, so let's assume they are unsigned values.  You can still get a zero
>value when adding two things if together they add up to exactly 2^32.
>
>The compiler has to care about this, so I don't see how this is the fault of the
>compiler.
>
>Perhaps your problem is with the language.  If the language allowed you to
>specify a range of values for each data-type, the compiler could catch this.
>
>>However i would need to learn assembly for this or i must rewrite
>>my C code. The compiler isn't smart Bruce. The compiler is very stupid
>>when talking about source connections. So i have to write:
>>  if( a+b )
>>    then do this and that;
>
>This is not the same as "a && b", as stated above, but if you can produce the
>same code as you can write in assembly, exactly what is the problem?
>
>>>Using pointers will usually help the compiler out, because it can just indirect
>>>through a value, rather than having to deal with scaling the value and adding it
>>>to a constant.  But in some circumstances, scaling it and adding it to a
>>>constant is free.
>>
>>In general the above construction makes no sense. Optimizing it with a
>>pointer is always safer!
>
>Sometimes it doesn't matter.
>
>bruce

But in general it matters so instead of wasting time figuring out
when to optimize and when not, i always go for the optimizing with
pointers!

I remember some years ago i had diep like nearly 10% faster when i mixed
chars with 32 bits integers. that's hell faster still today at all processors,
but i simply rewrote everything to integers and i am more happy about it
because i don't need to remember now whether something is 8 bits or 32 bits!





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.