Bug 42771 - [4.5 Regression][graphite] ICE: in graphite_loop_normal_form, at graphite-sese-to-poly.c (2)
Summary: [4.5 Regression][graphite] ICE: in graphite_loop_normal_form, at graphite-ses...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P1 normal
Target Milestone: 4.5.0
Assignee: Sebastian Pop
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-16 22:02 UTC by Zdenek Sojka
Modified: 2010-02-11 19:46 UTC (History)
4 users (show)

See Also:
Host: x86(_64)-pc-linux-gnu
Target: x86(_64)-pc-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-02-07 07:52:02


Attachments
original, unreduced testcase (from ffmpeg sources) (11.17 KB, text/plain)
2010-01-16 22:03 UTC, Zdenek Sojka
Details
reduced testcase (188 bytes, text/plain)
2010-01-16 22:05 UTC, Zdenek Sojka
Details
A further reduced case to show the ICE (185 bytes, text/plain)
2010-01-25 16:30 UTC, Ramakrishna Upadrasta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-01-16 22:02:07 UTC
The original, unreduced, testcase from pr42521 started crashing again, with the same error message. Only little modification to the reduced testcase is needed to reproduce it.

Command line:
gcc -O3 -fgraphite-identity -c testcase.c

Tested revisions (x86_64):
r155945 - crash (x86)
r155938 - crash
r155902 - crash
- r155881 - pr42732 fix (can be related)
r155844 - OK (x86)
r155833 - OK
- r155728 - pr42521 fix
r155363 - crash

Output:
$ /mnt/svn/gcc-trunk/binary-155945-x86-lto/bin/gcc -O3 -fgraphite-identity -c testcase.c
testcase.c: In function 'foo':
testcase.c:5:6: internal compiler error: in graphite_loop_normal_form, at graphite-sese-to-poly.c:2844
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Valgrind:
no errors reported
Comment 1 Zdenek Sojka 2010-01-16 22:03:43 UTC
Created attachment 19628 [details]
original, unreduced testcase (from ffmpeg sources)

Command line:
gcc -O3 -fgraphite-identity -c aes.i
Comment 2 Zdenek Sojka 2010-01-16 22:05:22 UTC
Created attachment 19629 [details]
reduced testcase

The only difference to the pr42521 testcase is added declaration of and call to bar()

Command line:
gcc -O3 -fgraphite-identity -c pr42771.c
Comment 3 H.J. Lu 2010-01-16 22:36:03 UTC
It is caused by the new implementation of Graphite:

http://gcc.gnu.org/ml/gcc-cvs/2009-07/msg01187.html
Comment 4 Ramakrishna Upadrasta 2010-01-25 16:30:07 UTC
Created attachment 19704 [details]
A further reduced case to show the ICE

Unable to find non-zero value for 'known_niter'.
Comment 5 Alexander Monakov 2010-01-25 17:06:45 UTC
We fail to find number of iterations after rewriting reductions out of SSA.  Before graphite pass, IR looks like (for the previous testcase, "pr42771.c"):

<bb 9>:
  # j_26 = PHI <j_20(10)>

<bb 10>:
  # j_33 = PHI <j_26(9), 1(16)>
  D.2747_16 = B[j_33][0];
  D.2748_17 = j_33 + -1;
  D.2749_18 = B[D.2748_17][0];
  D.2750_19 = D.2749_18 ^ D.2747_16;
  B[j_33][0] = D.2750_19;
  j_20 = j_33 + 1;
  if (jm_14(D) > j_20)
    goto <bb 9>;
  else
    goto <bb 11>;

At the time of the ICE, IR is transformed to
(gdb) call debug_loop(use_loop, 3)
loop_3 (header = 10, latch = 9, niter = (unsigned int) jm_14(D) + 4294967294, upper_bound = 2147483646)
{
  bb_9 (preds = {bb_10 }, succs = {bb_10 })
  {
  <bb 9>:
    # .MEM_24 = PHI <.MEM_78(10)>
    # VUSE <.MEM_24>
    j_26 = Close_Phi.13[0];
    # .MEM_79 = VDEF <.MEM_24>
    General_Reduction.14[0] = j_26;

  }
  bb_10 (preds = {bb_9 bb_16 }, succs = {bb_9 bb_11 })
  {
  <bb 10>:
    # .MEM_15 = PHI <.MEM_79(9), .MEM_77(16)>
    # VUSE <.MEM_15>
    D.2766_76 = General_Reduction.14[0];
    j_33 = D.2766_76;
    # VUSE <.MEM_15>
    D.2747_16 = B[j_33][0];
    D.2748_17 = j_33 + -1;
    # VUSE <.MEM_15>
    D.2749_18 = B[D.2748_17][0];
    D.2750_19 = D.2749_18 ^ D.2747_16;
    # .MEM_30 = VDEF <.MEM_15>
    B[j_33][0] = D.2750_19;
    j_20 = j_33 + 1;
    # .MEM_78 = VDEF <.MEM_30>
    Close_Phi.13[0] = j_20;
    if (jm_14(D) > j_20)
      goto <bb 9>;
    else
      goto <bb 11>;
  }
}

We would fail to discover scalar evolution of j_33.
Comment 6 Ramakrishna Upadrasta 2010-01-26 10:08:19 UTC
This PR is perhaps related to <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42644">PR42644</a> (equake problem) and <a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42130">PR42130</a> (DealII problem), as it has the 2^32-1 values as well as unsigned int in the cloog output.
Comment 7 Sebastian Pop 2010-02-07 07:52:02 UTC
Mine.
Comment 8 Sebastian Pop 2010-02-10 16:47:15 UTC
Subject: Bug 42771

Author: spop
Date: Wed Feb 10 16:47:04 2010
New Revision: 156664

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156664
Log:
Fix PR42771.

2010-02-10  Sebastian Pop  <seb@napoca>

	PR middle-end/42771
	* graphite-clast-to-gimple.c (gloog): Call rename_sese_parameters.
	* graphite-clast-to-gimple.h (gloog): Update declaration.
	* graphite-poly.c (new_scop): Clear POLY_SCOP_P.
	* graphite-poly.h (struct poly_bb): Add missing comments.
	(struct scop): Add poly_scop_p field.
	(POLY_SCOP_P): New.
	* graphite-sese-to-poly.c (build_poly_scop): Set POLY_SCOP_P.
	* graphite.c (graphite_transform_loops): Build the polyhedral
	representation for each scop before code generation.
	* sese.c (rename_variables_in_operand): Removed.
	(rename_variables_in_expr): Return the renamed expression.
	(rename_sese_parameters): New.
	* sese.h (rename_sese_parameters): Declared.

	* gcc.dg/graphite/pr42771.c: New.

Added:
    branches/graphite/gcc/testsuite/gcc.dg/graphite/pr42771.c
Modified:
    branches/graphite/gcc/ChangeLog.graphite
    branches/graphite/gcc/graphite-clast-to-gimple.c
    branches/graphite/gcc/graphite-clast-to-gimple.h
    branches/graphite/gcc/graphite-poly.c
    branches/graphite/gcc/graphite-poly.h
    branches/graphite/gcc/graphite-sese-to-poly.c
    branches/graphite/gcc/graphite.c
    branches/graphite/gcc/sese.c
    branches/graphite/gcc/sese.h

Comment 9 Sebastian Pop 2010-02-10 17:03:02 UTC
Fixed as described in 
http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00436.html
Comment 10 Alexander Monakov 2010-02-10 18:26:24 UTC
(In reply to comment #9)
> Fixed as described in 
> http://gcc.gnu.org/ml/gcc-patches/2010-02/msg00436.html
> 

I don't see how this patch makes simple_iv call from number_of_iterations_exit return true for j_20.  Could you please kindly explain?
Comment 11 sebpop@gmail.com 2010-02-11 00:29:15 UTC
Subject: Re:  [4.5 Regression][graphite] ICE: in 
	graphite_loop_normal_form, at graphite-sese-to-poly.c (2)

On Wed, Feb 10, 2010 at 12:26, amonakov at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
> I don't see how this patch makes simple_iv call from number_of_iterations_exit
> return true for j_20.  Could you please kindly explain?

We used to analyze the second scop after the code generation of the
first one.  In that context, the scalar evolution analysis failed to
analyze the code containing scalar computations stored and read from
arrays with 1 element (introduced by the code generation and analysis
part).  We now analyze all the scops before code generating them:
thus, we don't have to invalidate the scalar evolution hash tables
between the analysis of two scops.
Comment 12 Sebastian Pop 2010-02-11 19:42:50 UTC
Subject: Bug 42771

Author: spop
Date: Thu Feb 11 19:42:38 2010
New Revision: 156711

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156711
Log:
Fix PR42771.

2010-02-10  Sebastian Pop  <seb@napoca>

	PR middle-end/42771
	* graphite-clast-to-gimple.c (gloog): Call rename_sese_parameters.
	* graphite-clast-to-gimple.h (gloog): Update declaration.
	* graphite-poly.c (new_scop): Clear POLY_SCOP_P.
	* graphite-poly.h (struct poly_bb): Add missing comments.
	(struct scop): Add poly_scop_p field.
	(POLY_SCOP_P): New.
	* graphite-sese-to-poly.c (build_poly_scop): Set POLY_SCOP_P.
	* graphite.c (graphite_transform_loops): Build the polyhedral
	representation for each scop before code generation.
	* sese.c (rename_variables_in_operand): Removed.
	(rename_variables_in_expr): Return the renamed expression.
	(rename_sese_parameters): New.
	* sese.h (rename_sese_parameters): Declared.

	* gcc.dg/graphite/pr42771.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/graphite/pr42771.c
Modified:
    trunk/gcc/ChangeLog.graphite
    trunk/gcc/graphite-clast-to-gimple.c
    trunk/gcc/graphite-clast-to-gimple.h
    trunk/gcc/graphite-poly.c
    trunk/gcc/graphite-poly.h
    trunk/gcc/graphite-sese-to-poly.c
    trunk/gcc/graphite.c
    trunk/gcc/sese.c
    trunk/gcc/sese.h

Comment 13 Sebastian Pop 2010-02-11 19:46:00 UTC
Fixed.