Computer Chess Club Archives


Search

Terms

Messages

Subject: Interesting Assembly (OT)

Author: Matt Taylor

Date: 16:42:51 01/03/03

Go up one level in this thread


On January 03, 2003 at 13:37:25, Robert Hyatt wrote:

>On January 03, 2003 at 10:00:51, Graham Laight wrote:
>
>
>Here is a snippet of assembly produced by gcc, for the test
>
>if (x[1]==3 || x[1]==7) return(1);
>else return(0);
>
>        movl    x+4, %eax
>        cmpl    $3, %eax
>        sete    %dl
>        cmpl    $7, %eax
>        sete    %al
>        orl     %edx, %eax
>        testl   $1, %eax
>        sete    %al
>        movzbl  %al, %eax
>        ret
<snip>

Very interesting. I tried the same snippet using VC 7 and every optimization I
could find and got atrocious code:

        movl	x+4, %eax
        cmpl	$3, %eax
        je	L73439
        cmpl	$7, %eax
        je	L73439

        xorl	%eax, %eax
        ret

L73439:
        movl	$1, %eax
        ret


I'm also suprised that GCC missed saving these two cycles:
        movl    x+4, %eax
        cmpl    $3, %eax
        sete    %dl
        cmpl    $7, %eax
        sete    %al

        ; Should be using partial registers to avoid stall on P6/P7
        ;orl     %edx, %eax
        orb     %dl, %al

        ; Omit (redundant)
        ;testl   $1, %eax
        ;sete    %al

        movzbl  %al, %eax
        ret

I guess there is still room for hand-tweaking assembly code, though it is
obviously not worthwhile unless you need to start squeezing cycles out of code.

-Matt



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.