3 ms·
Author here; the non-vector loop still has a branch with a less than check if you do it the straightforward way. The whole benchmark is artificial, hence my wa
by xenadu02 11y ago
Author here; the non-vector loop still has a branch with a less than check if you do it the straightforward way.
The whole benchmark is artificial, hence my warning.
- Someone 11y agoThanks. I do not see that when I use what I would think to be the straightforward way to count (using integers), though: var count = Int() for var i in array { i += negBoundary let delta = (i > 0.0) ? 1 : 0 count += delta } (timed using mach_absolute_time(), on my system, that code also seems about twice as fast as the SIMD code) I did not check whether that trigraph gets compiled to a branch (I tried, but I had trouble reading the disassembly that otool gave me; I’m not used to x86, and I found the code surprisingly long)