Branches in branch-free code: why RV32's missing cmov leaks conditionals into adds

jedisct1 · x · 2026-10-09

Frank DENIS walks through a curious case: compiling a 128-bit unsigned add for rv32imac with clang -O2 yields a conditional beq inside an addition. RV32 lacks a conditional-move (cmov) instruction — even 64-bit comparisons produce branches — so LLVM must propagate carries across four 32-bit adds using checks like sum1 == b1. The post contrasts x86/AArch64 cmov-based carry propagation and revisits the bitmask ctselect pattern used in constant-time code.

Original post →

More from Research

Research channel →