Years ago (2005 I think) I entered an enhancement request into the GCC bugzilla asking for the use of the "conditional move" statement(s) where useful performance-wise. It was announced (IIRC) that this would be dealt with for versions 4.8.*, which is out. Haven't checked, though. Doing that now for some random library: % objdump -d libfxt.a | grep cmov | wc -l 749 It struck me only now that the question starting this "what if you have no 'if'?" is (if "if in disguise" is forbidden as well) "then the machine is not a computer". Best, jj * Tom Rokicki <rokicki@gmail.com> [Aug 24. 2013 19:20]:
gcc uses this trick:
solarium:~ rokicki$ cat t.c int mabs(int x) { if (x < 0) return -x ; return x ; } solarium:~ rokicki$ gcc -O5 -S t.c solarium:~ rokicki$ cat t.s ... _mabs: Leh_func_begin1: pushq %rbp Ltmp0: movq %rsp, %rbp Ltmp1: movl %edi, %ecx sarl $31, %ecx addl %ecx, %edi movl %edi, %eax xorl %ecx, %eax popq %rbp ret ... [...]