Computer Chess Club Archives


Search

Terms

Messages

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

Author: Tony Werten

Date: 00:03:03 04/10/03

Go up one level in this thread


On April 10, 2003 at 02:43:22, Uri Blass wrote:

>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];
>>x+=bonus;
>
>
>Do you say that 3 lines are faster than one line?(I guess you mean file1<=file2
>and not file1<file2 as you wrote in your next message)

It should have been file2>file1

>
>In any case it is only an example
>Practically I have a slightly different condition.
>
>if (file1+1<file2)
>>
>>The 2nd line basicly forces the compiler to use a CMOV.
>
>What does CMOV means?

Conditional move, ie a move depending on the outcome of a equation but it's
branchless. Its basic idea is like Robert said but then in hardware.

Tony

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