&amp;&amp; &#x2F;  ?: may not be “branching operations”, the compiler could determine that the operands have no side effects (q-&gt;score is used in both branches and q must be a valid or invalid pointer in both) and collapse that down to just register select operations and math internally. Or, it may involve predication, with only the assignment of i to a register previously filled with 0 being predicated. The compiler has heuristics internally to determine what it should accomplish via math only versus predication versus branching, based on how long code sequences are, whether it can determine if the predicates are warp-uniform or not, etc. You would need to look at the SASS to see what is really going on. Furthermore, there may be more or less functional units in the HW for each kind of operation that you think of substituting for the original; let the compiler choose first.<p>However, this is not the level of optimization one should be concerned with first (or even fifth) in a problem like this in CUDA. This kind of algorithm should be global memory bandwidth bound only. Concentrate on scanning through the data once and compacting as you go, so you touch as little memory as possible.