Any SIMD experts?

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 14:04:36 PST 2014


On 12/08/2014 05:55 PM, John Colvin wrote:
> I don't quite understand what you mean by "save one conditional".

Instead of
   if (v >= low && v < high)
it's
   if (cast(size_t)(v - low) < size)

So there is only one branch.
There are other ways to eliminate one branch, for example this.

   if ((v >= low) & (v < high))

But the interesting point was that the second branch actually helped the 
branch predictor. Because it seems to know that when the first branch is 
true the second will likely be true as well, respectively if it was 
false the 2nd one will be as well.


More information about the Digitalmars-d mailing list