------- Comment #1 from tkho at ucla dot edu 2005-11-18 02:35 ------- Created an attachment (id=10273) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10273&action=view) shift/mask long long testcase
Here is a rough instruction-count comparison for f() compiled at -O2, march=pentiumpro between icc9 and gcc head 20051108 with the patch in PR 17886, comment #16: icc: 11 gcc: 23 `icc -O2 -march=pentiumpro -S test3.c` gives: movl 4(%esp), %eax movl 8(%esp), %ecx movl %eax, %edx shrl $24, %edx shll $8, %eax shll $8, %ecx orl %ecx, %edx movzwl 18(%esp), %ecx movzbl %cl, %ecx orl %ecx, %eax ret `gcc -c test3.c -save-temps -O2 -march=pentiumpro -momit-leaf-frame-pointer` gives: subl $12, %esp movl %edi, 8(%esp) movl 28(%esp), %edi movl 16(%esp), %eax movl 20(%esp), %edx movl %esi, 4(%esp) movl 24(%esp), %esi movl %edi, %esi xorl %edi, %edi movl 8(%esp), %edi movl %ebx, (%esp) shrl $16, %esi xorl %ebx, %ebx shldl $8, %eax, %edx movl %esi, %ecx movl 4(%esp), %esi orl %ebx, %edx movl (%esp), %ebx andl $255, %ecx sall $8, %eax addl $12, %esp orl %ecx, %eax ret For comparison, here's the code from gcc 2.95.3. It generates the same 18 instructions for both march=i386 and march=pentiumpro. `gcc -c test3.c -save-temps -O2 -momit-leaf-frame-pointer -march=pentiumpro`: pushl %ebx movl 8(%esp),%ecx movl 12(%esp),%ebx movl 16(%esp),%eax movl 20(%esp),%edx shldl $8,%ecx,%ebx sall $8,%ecx movl %edx,%eax xorl %edx,%edx shrl $16,%eax andl $255,%eax andl $0,%edx orl %eax,%ecx orl %edx,%ebx movl %ecx,%eax movl %ebx,%edx popl %ebx ret -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24929