Author: Robert Hyatt
Date: 08:32:29 04/10/03
Go up one level in this thread
On April 10, 2003 at 04:32:19, José Carlos wrote: >On April 09, 2003 at 18:21:27, Daniel Clausen wrote: > >>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 > > Actually, it looks pretty much like: > >score += wtm ? bonus1 : bonus2; > > which is a very normal construct in C. > > José C. And also has a branch which we were trying to eliminate. :)
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.