TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Jonathan de Boyne Pollard
from: Mike Bilow
date: 1997-01-29 20:12:12
subject: Optimisation

Jonathan de Boyne Pollard wrote in a message to Mike Bilow:

MB>
  > From a machine level point of view, you want branches to be not taken
  > more frequently than taken.  This is because taking a branch
  > always flushes the prefetch instruction queue in the Intel
  > processors, [...]
MB>

 JdBP>   With speculative execution and branch prediction in 
 JdBP> processors like the Pentium Pro, or the Cyrix 5x86 and 6x86, 
 JdBP> I don't believe that this is as true as it used to be.

The Cyrix 5x86 does not do any speculative execution and the others do it
in a fairly rudimentary fashion.  In all cases, a branch taken flushes the
pipeline.  The Cyrix 6x86 does have some branch prediction capability, but
it really only works for certain specific although commonly encountered
code sequences.  No matter what the processor, arranging code so that
branches are not taken more often than they are taken is always a win.

 JdBP>   I sense a style war approaching, which is a pity, since it
 JdBP> isn't really a stylistic problem (at least, not to me --
 JdBP> as I said previously). 

I agree that it is not a style issue.

MB>
  > Unless you are in a truly critical area of the code, it is my opinion
  > that the paramount issue is source readability.
MB>

 JdBP>   Indeed, and again I think that it is nitpicking to say
 JdBP> that one is more   legible than the other.  More complex
 JdBP> examples, maybe.  But the cases in   question are pretty
 JdBP> much self-evident either way.

Well, take what I say as "source readability in the opinion of the
programmer."  Clearly, most programmers think one form or the other is
clearer to them, and compilers should be able to support this sort of
variation among personal preferences.  If a compiler really wanted to allow
a programmer to tell its optimizer whether a branch is more likely to be
taken or not taken, then it would have a #pragma for that purpose.  In
practice, this would be about as useless as the 'register' keyword.
 
-- Mike


--- 
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 50/99 54/99 270/101 620/243 625/160 711/401 413 430 934 712/311 407
SEEN-BY: 712/505 506 517 623 624 704 713/317 800/1
@PATH: 323/107 396/1 270/101 712/624 711/934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.