1. 6
  1.  

  2. 2

    Correct me if I’m wrong, because I’m sure there are people here who know more about this topic, but couldn’t the problem of unnecessary branching be fixed with conditional move instructions?

    For example, absolute value in pseudo-assembly:

    compare X 0
    move Y 1
    conditional-move-LT Y -1
    multiply X Y
    

    It seems like most of the mathematically unnecessary branches (i.e. where you’re just pulling different data, but not using different control flows) can be cleared out using conditional move instructions, which (IIRC) aren’t generated by most compilers for backward compatibility reasons.

    1. 4

      While conditional MOVs help caching, “branchless” code is also useful as a construct for building code resistant to side channel attacks.