Topics / Branchless programming

Performance topic

Branchless programming

Remove unpredictable branches: conditional moves, arithmetic on comparison results, lookup instead of if-chains, sorting networks.

885proven techniques
28pitfalls: tried, then slower
495repositories
44from papers

Examples from real commits

JuliaLang/julia 3.4× Compute eps(x) branch-free by flipping the mantissa LSB via bit reinterpretation, then returning abs(x - y) for the neighbouring float y. proof: commit → borgbackup/borg 3.3× Replace data-dependent if() carry and borrow reductions with __builtin_add/sub_overflow, so the flag is turned into a mask (sbb/adc) with no branch. proof: commit → facebook/fbthrift 2.6× Branch-free varint encoding: compute size from clz via lookup tables and deposit payload bits with a pdep-equivalent (SVE2 BDEP on arm64) instead of branching on value size. proof: commit →

Languages

  • C++340
  • C231
  • Rust111
  • Python26
  • CUDA20
  • Go18

Hardware

  • x86322
  • CPU207
  • ARM83
  • NVIDIA GPU46
  • GPU42

Fields

  • data & compression214
  • general193
  • math150
  • graphics116
  • CPU95

Where these come from

Repositories with the most techniques on this topic in the database:

Voultapher/sort-research-rs · 12flagos-ai/FlagGems · 7WojciechMula/base64simd · 6zeux/meshoptimizer · 6torvalds/linux · 6simdutf/simdutf · 6golang/go · 6vortex-data/vortex · 5Lokathor/wide · 5google/snappy · 5

Ask Claude for the full answer

Each technique comes with its bottleneck, measured speedup, trade-offs, conditions and the commit or paper behind it, served to Claude through MCP.

claude mcp add --transport http adtomic https://www.adtomic.co/mcp

Connect Claude Pricing

Related topics

Inlining and devirtualizationLookup tablesCache locality and data reorderingMultithreading and work stealingLoop unrolling and instruction-level parallelism