A conditional move transfers a value only when a Boolean predicate holds, while executing the same instruction sequence whether the predicate is true or false. After CMP, CMOVG moves its source to the destination when the compared value is greater. This avoids branch-path divergence and removes the processor’s need to predict a direction. section 10.5
Summing values above a threshold
A branching loop adds array[i] only when array[i] > threshold. A branchless replacement initializes increment to zero, compares array[i] with threshold, and uses CMOVG to replace increment with the element when the predicate holds. On a 100-million-element array, the unsorted branchless run takes 0.379 seconds versus 0.915 seconds with branching; after sorting, branching takes 0.302 seconds versus 0.362 seconds branchless.
