This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
mainline more jumpy than gcc-2.95.1 on x86
- To: gcc at gcc dot gnu dot org
- Subject: mainline more jumpy than gcc-2.95.1 on x86
- From: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- Date: Wed, 14 Mar 2001 02:03:54 -0800
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)...