This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/42646] New: Jump threading breaks canonical loop forms
- From: "joefoxreal at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Jan 2010 14:26:55 -0000
- Subject: [Bug tree-optimization/42646] New: Jump threading breaks canonical loop forms
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
pass_dominator tries to thread jumps.But sometimes this will cause that the
loop's exit bb does not dominator its latch bb again.
-------------------------------------
void
foo (int x)
{
int i;
for (i=0; i < 10 ; i++)
if (x)
{
if (i == 0)
fun_1 ();
else
fun_2 ();
}
}
---------------------------------------
$ gcc -O3 -S foo.c
$ cat foo.s
.file "foo.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
pushl %ebp
movl %esp, %ebp
pushl %ebx
movl $1, %ebx
subl $4, %esp
movl 8(%ebp), %eax
testl %eax, %eax
jne .L3
addl $4, %esp
popl %ebx
popl %ebp
ret
.p2align 4,,7
.p2align 3
.L7:
call fun_1
.L5:
addl $1, %ebx
.L3:
cmpl $1, %ebx
je .L7
call fun_2
cmpl $9, %ebx
jle .L5
addl $4, %esp
popl %ebx
popl %ebp
ret
.size foo, .-foo
.ident "GCC: (GNU) 4.5.0 20100107 (experimental)"
.section .note.GNU-stack,"",@progbits
-------------------------------------------
$ gcc -O3 -fno-tree-dominator-opts -S foo.c
$ cat foo.s
.file "foo.c"
.text
.p2align 4,,15
.globl foo
.type foo, @function
foo:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
movl 8(%ebp), %eax
testl %eax, %eax
je .L1
call fun_1
call fun_2
.p2align 4,,5
call fun_2
.p2align 4,,5
call fun_2
.p2align 4,,5
call fun_2
.p2align 4,,5
call fun_2
.p2align 4,,5
call fun_2
.p2align 4,,5
call fun_2
.p2align 4,,5
call fun_2
leave
jmp fun_2
.p2align 4,,7
.p2align 3
.L1:
leave
ret
.size foo, .-foo
.ident "GCC: (GNU) 4.5.0 20100107 (experimental)"
.section .note.GNU-stack,"",@progbits
-------------------------------------------
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/eric/install/trunk/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../trunk/configure --prefix=/home/eric/install/trunk
--with-gmp=/home/eric/install/generic
--with-mpfr=/home/eric/install/generic
--with-mpc=/home/eric/install/generic/ --enable-languages=c
Thread model: posix
gcc version 4.5.0 20100107 (experimental) (GCC)
--
Summary: Jump threading breaks canonical loop forms
Product: gcc
Version: tree-ssa
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: joefoxreal at gmail dot com
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42646