This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

mainline more jumpy than gcc-2.95.1 on x86


Hi!

For the following small function:
(stolen from  http://gcc.gnu.org/projects/optimize.html)

int and(int a, int b) { return (a && b); }


the current mainline outputs the following for x86-linux 
(for -O2):


and:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %ecx
        xorl    %eax, %eax
        testl   %ecx, %ecx
        je      .L3
        movl    12(%ebp), %edx
        testl   %edx, %edx
        je      .L3
        movl    $1, %eax
.L3:
        popl    %ebp
        ret

notice there are 2 jumps to .L3

whereas gcc-2.95.1 outputs:

and:
        pushl %ebp
        movl %esp,%ebp
        xorl %eax,%eax
        cmpl $0,8(%ebp)
        je .L3
        cmpl $0,12(%ebp)
        setne %al
        andl $255,%eax
.L3:
        leave
        ret


just one jump here.

Is this because GCC thinks branches are realy cheap, or there's some
other cause? 

I don't know if this is a problem in more complex code, but somebody
might want to investigate (given that the common wisdom is that
branches are bad)... 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]