------- Comment #1 from navin dot kumar at gmail dot com 2010-08-07 01:29 ------- The assembly generated for foo1 & foo2 (under -O3) are identical: leaq -4(%rdi), %rdx xorl %eax, %eax testq %rdi, %rdi cmovne %rdx, %rax movl 8(%rax), %eax ret
The assembly generated for foo3 is the most optimal: movl 4(%rdi), %eax ret -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45221