On 5/19/15 2:35 AM, Martin Nowak wrote:
On Tuesday, 19 May 2015 at 07:56:27 UTC, Atila Neves wrote:
Aren't predictable branches cheap on current architectures?
Yes they are, and it seems one would rarely if ever call isPowOf2 with 0
in std.allocator. A good thing to do, is to use a good hardware event
profiler like perf, and record the branch misses. Perf is also the right
tool to compare the branchless version (I doubt it's significantly
better, especially since the felt of the 0 branch is just a constant).
Yah measuring on-line is clearly the way to go. A comment on the
branches - the branch predictor has a limited capacity so branching here
might take resources away from other places. -- Andrei