Hacker GitHub

← All repos

ehrmann/branchless-binary-search

View on GitHub ↗ ★ 10 C

Binary search implementation that avoids branch instructions

4 mentions on Hacker News by 1 person: 0 stories, 4 comments · first 2020-07-20 · latest 2025-09-29

Mentions per year 4 mentions · busiest year 2023 (2)
20082026
  1. …I could be clever enough with bitwise operators to do it and 2) someday write a SIMD binary search. https://github.com/ehrmann/branchless-binary-search
  2. …change the result, you can use a switch fallthrough to "unroll" the loop and not have to branch. https://github.com/ehrmann/branchless-binary-search/blob/mas...
    comment by dehrmann · 2023-08-11 · in Fastest branchless binary search
  3. Shameless plug of my attempt at this: https://github.com/ehrmann/branchless-binary-search
    comment by dehrmann · 2023-04-28 · in Beautiful branchless binary search
  4. …with SIMD instructions. I think I was able to get it with some optimizer flags and GCC built-ins. https://github.com/ehrmann/branchless-binary-search