Author: Sune Fischer
Date: 02:28:03 11/19/02
Go up one level in this thread
On November 19, 2002 at 04:57:50, Gerd Isenberg wrote:
>Therefore it is often possible to replace some conditional assignments or simple
>if[else] statements by some cheap test,cmp,setcc,shift,add or lea instructions:
>
>c = a > b ? 32 : 16;
>c = 16 + 16*(a>b);
is that legal, will a>b (true or false) always be 1 or 0?
Because usually expressions like:
if (x) {...}
just means x!=0.
>// color [0,1] ==> white,black
>delta = color == WHITE ? 8 : -8;
how about:
delta = -8*(((color)<<1)-1)
since it is easy (mathematicly) to transform [1,0] to [1;-1]:
y=2*x-1 - with no conditional :)
-S.
>delta = pawnDelta[color]; // no conditional jumps but memory access
>
>delta = 8 - 16*color; // should procuce the fastest code
>
>See also amd's Optimization Guide, Chapter 6, Branch Optimizations:
>
>http://www.amd.com/us-en/Processors/DevelopWithAMD/0,,30_2252_739_2983,00.html
>http://www.amd.com/us-n/assets/content_type/white_papers_and_tech_docs/22007.pdf
>
>Cheers,
>Gerd
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.