Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: question about importance of branchless code for speed

Author: Robert Hyatt

Date: 14:59:18 04/09/03

Go up one level in this thread


On April 09, 2003 at 12:29:20, Daniel Clausen wrote:

>On April 09, 2003 at 12:12:22, Robert Hyatt wrote:
>
>>if (wtm == 1)
>>  score+=bonus1
>>else
>>  score+=bonus2;
>>
>>You could turn that into:
>>
>>score+=wtm*bonus1 + (wtm^1)*bonus2;
>>
>>the new code does more work, but has no branch to mispredict.
>
>And it's soo incredibly readable. :p I know this is not the discussion here, but
>I wanted to point the out nevertheless. :)
>
>Sargon


In that case, yes.  But in other cases, it is much harder to read because both
sides of the
"branch" are encoded into a single instruction and it is not clear what is going
on....



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.