Computer Chess Club Archives


Search

Terms

Messages

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

Author: Daniel Clausen

Date: 15:21:27 04/09/03

Go up one level in this thread


On April 09, 2003 at 17:59:18, Robert Hyatt wrote:

>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....

Um.. I'm not sure I understand you now.. are you saying that you find the
version "score+=wtm*bonus1 + (wtm^1)*bonus2" more readable?

In this case I'm a tad surprised.

Sargon



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.