------- Comment #1 from msebor at gmail dot com 2009-09-12 23:33 ------- Code involving bool variables is similarly suboptimal:
$ cat t.cpp && gcc -O2 -S t.cpp && cat t.s bool foo (bool a, bool b) { return a && b || !a && !b; } bool bar (bool a, bool b) { return a == b; } .file "t.cpp" .text .p2align 4,,15 .globl _Z3foobb .type _Z3foobb, @function _Z3foobb: .LFB0: .cfi_startproc .cfi_personality 0x3,__gxx_personality_v0 movl %esi, %edx movl %esi, %eax xorl $1, %edx testb %dil, %dil cmove %edx, %eax ret .cfi_endproc .LFE0: .size _Z3foobb, .-_Z3foobb .p2align 4,,15 .globl _Z3barbb .type _Z3barbb, @function _Z3barbb: .LFB1: .cfi_startproc .cfi_personality 0x3,__gxx_personality_v0 cmpb %dil, %sil sete %al ret .cfi_endproc .LFE1: .size _Z3barbb, .-_Z3barbb .ident "GCC: (GNU) 4.4.1 20090725 (Red Hat 4.4.1-2)" .section .note.GNU-stack,"",@progbits -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38126