Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Move generation question for the big boys

Author: Heiner Marxen

Date: 04:54:55 09/16/01

Go up one level in this thread


On September 16, 2001 at 05:16:42, Rafael Andrist wrote:

>On September 15, 2001 at 19:52:11, Vincent Diepeveen wrote:
>
>>On September 15, 2001 at 17:57:03, Rafael Andrist wrote:
>>
>
>>>; reading from memory
>>>; do something else to avoid AGI stall
>>>or  eax, edx
>>>jnz loop1
>>
>>using that can you still get a misprediction penalty somehow?
>
>You can get allways a misprediction of conditional jumps. In special cases there
>are some tricks to avoid conditional jumps:
>example in VC++
>
>unoptimized:
>
>unsigned __int32 i, j;
>//some code involving i and j
>if ( (i & 0x00000010) != 0 ) j++;
>
>
>
>optimized:
>
>unsigned __int32 i, j;
>//some code involving i and j
>j += (i & 0x00000010) >> 4;

Ah, yes!  That is a very fine example of how to replace conditional code
by unconditional code, thus avoiding an (expensive) conditional branch.

But this is architecture dependant.
IIRC, on the PDP-11 I did prefer the first over the second.
Also, on an architecture with (efficient) conditional instruction skip
the first may be preferrable.

Therefore I ofter prefer to use the more intuitive version, and hope
for a good optimizer to recognize the equivalence of both versions,
and choose the one, which is better today.
(Some years ago, when I last tuned the code generation of a C compiler
 I did some patterns like the above, so this is not very unrealistic.
 No, I'm not sure it is done in todays compilers, but it is quite doable.)

Cheers,
Heiner



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.