Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: [OT] coding tricks (Was: Experimentation with move ordering)

Author: Eugene Nalimov

Date: 01:49:51 12/02/00

Go up one level in this thread


On December 01, 2000 at 11:54:07, Dieter Buerssner wrote:

>On November 30, 2000 at 19:50:46, Eugene Nalimov wrote:
>
>>Second, there are better ways to add the value to the register only if register
>>is negative. Let's look at the following C code:
>>
>>    t = (x < 0) ? 255 : 0;
>>    x += t;
>>    x >>= 8;
>>
>>One some CPUs there are 'conditional move' instructions. Examples are IA-64,
>>Alpha, PentiumPro and up (PII, PIII, PIV). So on PentiumPro and later CPU you
>>can use
>>
>>    xor   edx, edx
>>    test  eax, eax
>>    cmovl edx, 255
>>    add   eax, edx
>>    shr   eax, 8
>
>Perhaps, I am totally confused. Otherwise, I would think, that the last line
>should read
>
>    sar eax, 8 ; Use arithmetic shift

Of course you are right, I just forgot exact mnemonics.

>Also in the next example, that I snipped.
>
>Is cmovl fast? My assembler knowledge is from 8086 days and was only updated
>for 386 upcodes :-( From that I remember, that the conditional set.. upcodes
>were rather slow. Also, using the carry flag, may not not be very "easy"
>for a pipelined CPU.

On P6 family (PentiumPro, PII, PIII) conditional move is 3 uops. In any case,
it's better than either division or branch. And variant with CDQ is better.

>Regards,
>Dieter



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.