Bug 36908 - bootstrap forever with BOOT_CFLAGS="-O2 -ftree-loop-distribution"
Summary: bootstrap forever with BOOT_CFLAGS="-O2 -ftree-loop-distribution"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build, wrong-code
Depends on:
Blocks:
 
Reported: 2008-07-23 13:22 UTC by tomby
Modified: 2008-11-03 16:36 UTC (History)
3 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work: 4.3.1
Known to fail: 4.4.0
Last reconfirmed:


Attachments
Testcase where loop distribution enabled makes run of binary forever (474 bytes, text/plain)
2008-07-28 11:53 UTC, tomby
Details
1263_ldist_pr36908.diff (1.28 KB, patch)
2008-10-22 21:08 UTC, sebpop@gmail.com
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description tomby 2008-07-23 13:22:39 UTC
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)
Comment 1 tomby 2008-07-28 11:53:36 UTC
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.
Comment 2 Andrew Pinski 2008-08-16 23:36:51 UTC
I don't see why this is a P1, -ftree-loop-distribution is not enabled default at all.
Comment 3 Jakub Jelinek 2008-09-02 16:44:53 UTC
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?
Comment 4 Jakub Jelinek 2008-10-21 12:51:16 UTC
Dropping [4.4 Regression], as -ftree-loop-distribution is a new option.
Sebastian, can you please look at this?
Comment 5 sebpop@gmail.com 2008-10-22 21:08:42 UTC
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
Comment 6 sebpop@gmail.com 2008-10-22 21:08:43 UTC
Created attachment 16529 [details]
1263_ldist_pr36908.diff
Comment 7 Sebastian Pop 2008-11-03 16:36:41 UTC
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

Comment 8 Sebastian Pop 2008-11-03 16:36:50 UTC
Fixed.