Bootstrap with BOOT_CFLAGS set to "-O2 -ftree-loop-distribution" runs "forever" (at least 12 hours then I break compilation). It seems that genautomata in stage2 run in cycle in merge_states. configured as: Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/abuild/tbily/install/ --enable-bootstrap --disable-multilib --enable-checks --enable-languages=c,c++ Thread model: posix gcc version 4.4.0 20080723 (experimental) (GCC)
Created attachment 15971 [details] Testcase where loop distribution enabled makes run of binary forever Compilation with CFLAGS="-O2" and running of testcase is ok (it finish). Compilation with CLFLAGS="-O2 -ftree-loop-distribution" and running testcase makes it run forever (last loop cycles). Inlined loop from free_alt_states is wrongly distributed.
I don't see why this is a P1, -ftree-loop-distribution is not enabled default at all.
Why got this even marked as regression? GCC 4.3.1 didn't support -ftree-loop-distribution, it is a new option, so it can't regress. The loop in question is: <bb 8>: # state_89 = PHI <state_17(9), state_5(7)> # prephitmp.18_6 = PHI <state_89(9), pretmp.17_59(7)> state_17 = state_89->next_alt_state; state_89->next_alt_state = prephitmp.18_6; first_free_alt_state_lsm.29_18 = state_89; if (state_17 != 0B) goto <bb 9>; else goto <bb 10>; <bb 9>: goto <bb 8>; and gets distributed into: <bb 16>: # state_62 = PHI <state_22(17), state_5(7)> # prephitmp.18_26 = PHI <state_62(17), pretmp.17_59(7)> state_22 = state_62->next_alt_state; state_62->next_alt_state = prephitmp.18_26; if (state_22 != 0B) goto <bb 17>; else goto <bb 18>; <bb 17>: goto <bb 16>; <bb 18>: # prephitmp.18_90 = PHI <prephitmp.18_26(16)> <bb 8>: # state_89 = PHI <state_17(9), state_5(18)> state_17 = state_89->next_alt_state; state_89->next_alt_state = prephitmp.18_90; first_free_alt_state_lsm.29_18 = state_89; if (state_17 != 0B) goto <bb 9>; else goto <bb 10>; <bb 9>: goto <bb 8>; Perhaps tree-loop-distribution.c is confused by a PHI depending on previous PHI result?
Dropping [4.4 Regression], as -ftree-loop-distribution is a new option. Sebastian, can you please look at this?
Subject: Re: bootstrap forever with BOOT_CFLAGS="-O2 -ftree-loop-distribution" > Sebastian, can you please look at this? Sorry for having missed this bug. The problem here is that we end with two identical loops, as we copy almost all the statements in both loops. The attached patch solves the problem by counting the number of memory read and write operations per partition and compares it to the total number of memory operations in the Reduced Dependence Graph. Loop distribution is stopped when one of the partitions contains all the memory ops. Okay for trunk once it finishes regstrap? Thanks, Sebastian
Created attachment 16529 [details] 1263_ldist_pr36908.diff
Subject: Bug 36908 Author: spop Date: Mon Nov 3 16:35:13 2008 New Revision: 141550 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141550 Log: 2008-11-03 Sebastian Pop <sebastian.pop@amd.com> PR tree-optimization/36908 * testsuite/gcc.dg/tree-ssa/pr36908.c: New. * tree-loop-distribution.c (number_of_rw_in_rdg): New. (number_of_rw_in_partition): New. (partition_contains_all_rw): New. (ldist_gen): Do not distribute when one of the partitions contains all the memory operations. Added: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr36908.c Modified: trunk/gcc/ChangeLog trunk/gcc/tree-loop-distribution.c
Fixed.