Always a good idea to give a hand to the compiler, but be aware that it's not granted that a C jumpless code is compiled to a binary jumpless one...
Usually, when using optimizations, the compiler will try to eliminate jumps, even with conditional ("if' or "?" operator) and loops... But it always will try to create faster code (with options as -O2 or -O3), using jumps or not.
Here's an example:
Code:
int f( int x, int b )
{ return x + ( x && b ); }
int g( int x, int b )
{
if ( x && b )
x++;
return x;
}
The g() function isn't jumpless (in C) and isn't jumpless in assembly:
Code:
f: g:
test edi, edi mov eax, edi
setne dl test edi, edi
xor eax, eax je .L4
test esi, esi test esi, esi
setne al setne dl
and eax, edx cmp dl, 1
add eax, edi sbb eax, -1
ret .L4:
ret
But g() is faster. If x is 0 there's a penalty for the forward conditional jump, but it is way faster than executing 5 instructions (before ret).
if x isn't zero, the performance is equivalent for 1 less instruction than f().