From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20120 invoked by alias); 7 Jan 2010 14:27:13 -0000 Received: (qmail 19743 invoked by uid 48); 7 Jan 2010 14:26:55 -0000 Date: Thu, 07 Jan 2010 14:27:00 -0000 Subject: [Bug tree-optimization/42646] New: Jump threading breaks canonical loop forms X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "joefoxreal at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-01/txt/msg00775.txt.bz2 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