This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: x86 code generation question
Testing...
#define sel(x,y,s) ((s) ? (y) : (x))
int test (int x, int y, int s)
{
return sel(x,y,s);
}
gcc -O2 -march=i686 -S test.c
produces
.file "test.c"
.text
.p2align 4,,15
.globl test
.type test, @function
test:
pushl %ebp
movl %esp, %ebp
movl 16(%ebp), %edx
movl 12(%ebp), %eax
testl %edx, %edx
cmove 8(%ebp), %eax
popl %ebp
ret
So indeed the conditional move does happen. It may be that you didn't
see it because you didn't ask for optimization, or didn't specify the
CPU type and ended up with i386 by default.
This was with GCC 3.3.2.
paul