
-------------------------------------------------------------
I've  designed CPUs for over 30 years and we pay a 
LOT of attention breaks in code streams.  Branch prediction, 
speculative execution, and even register reassignments 
are all about minimizing branch and pipeline impacts. 
 What you may be missing in the above examples is 
that what seems to be avoiding branches ... don't. 
 Every conditional test is a branch.  Every conditional 
assignment is a branch.  It is hard to beat the compiler 
optimization that understands the pipeline of the 
processor it's targeting.  Clever manual decimation 
can be effective for long pipelines, such in GPUs, 
but even then compilers are pretty smart.  The most 
efficient code is when tasks are parallelized so that 
multiple operations can be done based off of one or 
a small number of decisions.

In trying to avoid branches, the cost is paid in non-maintainable 
code and is very high.  If you really want to improve 
efficiency, don't rely on multiple software packages 
which actually may include interpreted languages somewhere 
underneath the shiny API.  Layering of packages and 
the use of  interpreted languages (Python, PERL, etc.) 
waste much of the increasing performance of processors. 
 Yes, it means recompiling for a new processor, but 
one does that if efficiency is required.

In one example, we recoded a numeric-heavy program 
that was synthesizing frequencies for an electronic 
piano.  Recasting it to vector operations allowed 
the program to run on a very inexpensive Beagle-Bone 
Black instead of a MAC.  On the MAC it consumed 35% 
of the processor. On the BBB it used 15% of a much 
less powerful processor by vectorizing the operations. 
 These are the sorts of changes that matter.

-------------------------------------------------------------

