News for hackers. Stuff that matters.
Re:Beautiful branchless binary search by berkut on Friday April 28, 2023 @03:12AM (#35738413)
Yeah, it's mildly annoying there's no (at least to my knowledge?) compiler hint like the '__builtin_expect' ones to tell compilers that the values are very unlikely going to be predictable with enough accuracy to allow the branch predictors to be useful in general, and to use a cmov instead of the traditional branching instructions because of this.
Re:Beautiful branchless binary search by dist1ll on Friday April 28, 2023 @03:21AM (#35738478)
Re:Beautiful branchless binary search by berkut on Friday April 28, 2023 @03:22AM (#35738484)
Oooooh :)

Thanks!

Re:Beautiful branchless binary search by usefulcat on Friday April 28, 2023 @04:57PM (#35747016)
It does, but unfortunately it doesn't always work. For example (note the -march=broadwell option):

https://godbolt.org/z/n1Kz4G7GE

Re:Beautiful branchless binary search by gpderetta on Friday April 28, 2023 @05:11AM (#35739092)
GCC has __builtin_expect_with_probability now. YMMV.