For most platforms, you can assume that the conditional will be faster. This is because most modern architecture where branch mispredictions are expensive have some form of conditional move instruction, which the compiler will utilize to perform the requested check & assignment. For example, my gcc translates this:
n++; if (n==1234) n=0;
into this for x86_64 (and x86):
addl $1, %esi ; %esi=n
cmpl $1234, %esi
cmove %edx, %esi ; %edx contains 0
(cmove is available since PentiumPro.)
This comes out for ARM-thumb:
add r3, r3, #1
cmp r3, r1
moveq r3, #0 ; <- conditional move
All ARMs have conditional execution.
And so. To wrap it up: You'd need an architecture with
- Very fast division/modulo
- Expensive branch mispredictions
- no conditional move
to end up with the modulo trick as being the fastest. *If there is such an architecture, then please tell me about it. I'm always interested in such things.