This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
bbreorder odity
- To: gcc at gcc dot gnu dot org
- Subject: bbreorder odity
- From: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- Date: Wed, 14 Mar 2001 02:27:02 -0800
Hi!
Compiling the following
(stolen from http://gcc.gnu.org/projects/optimize.html):
int or (int a, int b) { return (a || b); }
with the mainline GCC with -O2 on linux-x86 I get:
or:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %ecx
xorl %eax, %eax
testl %ecx, %ecx
je .L5
.L4:
movl $1, %eax
.L3:
popl %ebp
ret
.p2align 4,,7
.L5:
movl 12(%ebp), %edx
testl %edx, %edx
jne .L4
jmp .L3
^^^^^
Should it reorder block here? It adds a jump to one of the paths, and
that is the jump to the epilogue. Shouldn't the epilogue be duplicated
here instead of using a jump?
with -O2 -fno-reorder-blocks
or:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne .L4
movl 12(%ebp), %edx
testl %edx, %edx
je .L3
.L4:
movl $1, %eax
.L3:
popl %ebp
ret
The odd thing is that the epilogue is duplicated when using
-O2 -fomit-frame-pointer
or:
movl 4(%esp), %ecx
xorl %eax, %eax
testl %ecx, %ecx
je .L5
.L4:
movl $1, %eax
ret
.p2align 4,,7
.L5:
movl 8(%esp), %edx
testl %edx, %edx
jne .L4
ret
I don't know if any of these are real problems, but I thought they are
worth mentioning.