On Monday, 8 December 2014 at 16:32:50 UTC, Martin Nowak wrote:
Usually (scalar) I'd use this, which makes use of unsigned wrap to safe one conditional

immutable size = cast(ulong)(vhigh - vlow);
if (cast(ulong)(v0 - vlow) < size) {}
if (cast(ulong)(v1 - vlow) < size) {}

over

if (v0 >= vlow && v0 < vhigh) {}

Maybe this can be used on SIMD too (saturated sub or so)?

-Martin

This is for the most performance critical instructions during GC marking. If we can come up with some good SIMD this will result in a good speedup.

Yesterday I was surprised to learn that my unsigned wrap trick actually slowed down some GC benchmarks by 3%. The branch predictor had more trouble with the single branch because that resulted in a fifty-fifty chance. There is some correlation between the 2 branch bounds checks and one of them could be predicted fairly well, resulting in a better combined result.
Always profile!

Reply via email to