Are compilers able to avoid branching instructions? <p>I've been reading about <a href="http://www.graphics.stanford.edu/~seander/bithacks.html" rel="nofollow">bit twiddling hacks</a> and thought, are compilers able to avoid branching in the following code:</p> <pre><code>constexpr int min(const int lhs, const int rhs) noexcept { if (lhs &lt; rhs) { return lhs; } return rhs } </code></pre> <p>by replacing it with (<a href="http://www.graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax" rel="nofollow">explanation</a>):</p> <pre><code>constexpr int min(const int lhs, const int rhs) noexcept { return rhs ^ ((lhs ^ rhs) &amp; -(lhs &lt; rhs)); } </code></pre>