Computer Chess Club Archives


Search

Terms

Messages

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

Author: Tony Werten

Date: 23:10:02 04/09/03

Go up one level in this thread


On April 10, 2003 at 02:08:36, Tony Werten wrote:

>On April 09, 2003 at 11:11:01, Uri Blass wrote:
>
>>Supppose file1 and file2 are numbers between 0 and 7.
>>
>>Am I correct to assume that in general it is better to not to use
>>
>>int A[8];
>>If (file1<=file2) x+=A[file2-file1];
>
>Most modern compilers will do better with:
>
>bonus=0;
>if (file1>file2) bonus=A[file2-file1];

Oops, (file2>file1)

>x+=bonus;
>
>The 2nd line basicly forces the compiler to use a CMOV. It might also work with
>less forcing, but this way you are sure.
>
>Tony
>
>>
>>
>>but instead of it something like
>>
>>int PADDED_A[15];
>>int * const A = PADDED_A+7;
>>x+=A[file2-file1];
>>
>>\\A[x]=0 for x=-1,x=-2,...x=-7
>>
>>
>>Uri



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.