Bug 45450 - [graphite] some programs do not pass the legality check
Summary: [graphite] some programs do not pass the legality check
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-30 10:04 UTC by Baghdadi Riyadh
Modified: 2011-07-27 16:53 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Baghdadi Riyadh 2010-08-30 10:04:26 UTC
In the graphite branch some programs do not pass the legality check with the following flags:

$ gcc -O3 -fgraphite -fno-loop-block run-id-pr42644.c
When executed, the program cannot pass any legality check similar to :
gcc_assert (graphite_legal_transform (scop));

Test files that have the same problem are :
id-17.c
id-1.c
pr37828.c
pr38510.c
pr38786.c
pr39335_1.c
pr39335.c
pr42211.c
run-id-pr42644.c

To produce the error you'll need to insert this test manually since the test is not accessible by default. (it's called when you activate the option -fgraphite-write, and after code transformation, code transformation make the check pass but if the check is inserted before code transformation, there will be an error). 
The same bug was also there without when I use a graphite version without any recent OpenScop patches, so it's not related to recent changes by OpenScop patches.
Comment 1 Sebastian Pop 2011-07-26 21:07:33 UTC
I went to investigate this bug, and I found out that inserting
  gcc_assert (graphite_legal_transform (scop));
is invalid: the legality function is not supposed to return true
when the dependence analysis cannot be performed at compile time.

On the particular case of id-1.c, we have this code:

lambda_vector_add_mc (lambda_vector vec1, int const1,
		      lambda_vector vec2, int const2,
		      lambda_vector vec3, int size)
{
  int i;
  for (i = 0; i < size; i++)
    vec3[i] = const1 * vec1[i] + const2 * vec2[i];
}

and the assert would fail because the dependence analysis
returns a relation classified as unknown because it is not
possible to prove that vec1 and vec3 do not alias:

  if (!(pdr_read_p (pdr1) && pdr_read_p (pdr2))
      && PDR_BASE_OBJECT_SET (pdr1) != PDR_BASE_OBJECT_SET (pdr2)
      && may_alias)
    PDDR_KIND (res) = unknown_dependence;

I investigated the other fails that I can see today on trunk:

FAIL: gcc.dg/graphite/scop-matmult.c (internal compiler error)
FAIL: gcc.dg/graphite/scop-mvt.c (internal compiler error)
FAIL: gcc.dg/graphite/id-1.c (internal compiler error)
FAIL: gcc.dg/graphite/run-id-pr42644.c (internal compiler error)
FAIL: gcc.dg/graphite/interchange-14.c (internal compiler error)
FAIL: gcc.dg/graphite/interchange-15.c (internal compiler error)
FAIL: gcc.dg/graphite/interchange-mvt.c (internal compiler error)
FAIL: gcc.dg/graphite/pr31183.c (internal compiler error)
FAIL: gcc.dg/graphite/pr38510.c (internal compiler error)
FAIL: gcc.dg/graphite/pr38786.c (internal compiler error)
FAIL: gcc.dg/graphite/pr42211.c (internal compiler error)

FAIL: libgomp.graphite/pr41118.c (internal compiler error)

FAIL: gfortran.dg/graphite/pr29581.f90  -O0  (internal compiler error)
FAIL: gfortran.dg/graphite/pr29832.f90  -O0  (internal compiler error)
FAIL: gfortran.dg/graphite/pr42334-1.f  -O  (internal compiler error)
FAIL: gfortran.dg/graphite/pr42393-1.f90  -O  (internal compiler error)
FAIL: gfortran.dg/graphite/pr42393.f90  -O  (internal compiler error)

when run in gdb, they all break on the statement before ICE-ing:
  PDDR_KIND (res) = unknown_dependence;

I am closing this bug as invalid.
Comment 2 Sebastian Pop 2011-07-27 16:53:06 UTC
Author: spop
Date: Wed Jul 27 16:53:02 2011
New Revision: 176837

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176837
Log:
PR45450: disable legality check after an openscop read

2011-07-27  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/45450
	* graphite-poly.c (apply_poly_transforms): Disable legality check
	after an openscop read.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/graphite-poly.c