Bug 42326 - [4.5 Regression][graphite] segfault in tree-data-ref.c with Graphite building 200.sixtrack
Summary: [4.5 Regression][graphite] segfault in tree-data-ref.c with Graphite building...
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: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-12-07 21:22 UTC by Janis Johnson
Modified: 2010-03-08 17:51 UTC (History)
4 users (show)

See Also:
Host:
Target: powerpc-linux
Build:
Known to work: 4.4.2
Known to fail:
Last reconfirmed: 2009-12-14 19:24:51


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janis Johnson 2009-12-07 21:22:58 UTC
GCC trunk gets an internal compiler error when building SPEC CPU2000 test 200.sixtrack with "-O2 -floop-parallelize-all -fprefetch-loops-arrays" on powerpc-linux, as demonstrated by this minimized testcase:

      subroutine phasad(t,i,ium)
      implicit none
      real t(5,4)
      integer i,l,ll,ium

      do l=1,2
        ll=2*l
        do i=1,ium
          t(i,ll-1)=t(i,ll-1)+t(i,ll)
        enddo
      enddo
      return
      end

elm3b149% /home/janis/tools/gcc-trunk-anonsvn/bin/gfortran -c -O2 -floop-parallelize-all -fprefetch-loop-arrays bug.f
bug.f: In function ‘phasad’:
bug.f:1:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The failure has existed since the large Graphite merge that introduced -fgraphite-force-parallel which was later renamed to -floop-parallelize-all.

The segmentation fault occurs in initialize_matrix_A at tree-data-ref.c:1914 when A[index] has the value (lambda_vector) 0xa.
Comment 1 Janis Johnson 2009-12-08 00:31:12 UTC
This testcase minimized from 173.applu fails in the same place when compiled with "-m32 -O2 floop-strip-mine -fprefetch-loop-arrays" on powerpc64-linux.

      subroutine blts ( ldmx, ldmy, v, tmp1, i, j, k)
      implicit none
      integer ldmx, ldmy, i, j, k, ip, m, l
      real*8 tmp, tmp1, v( 5, ldmx, ldmy, *), tmat(5,5)

      do ip = 1, 4
        do m = ip+1, 5 
          tmp = tmp1 * tmat( m, ip )
          do l = ip+1, 5
            tmat( m, l ) =  tmat( m, l ) - tmat( ip, l )
          end do
          v( m, i, j, k ) = tmp
        end do
      end do
      return
      end
Comment 2 Sebastian Pop 2009-12-14 19:24:51 UTC
Mine.
Comment 3 Sebastian Pop 2009-12-14 19:41:11 UTC
I cannot reproduce this bug (both testcases) on amd64-linux on trunk revision 155219.
Could you please try again to see if this has been resolved?

Thanks,
Sebastian
Comment 4 Dominique d'Humieres 2009-12-14 21:38:10 UTC
I see it for both reduced tests on powerpc-apple-darwin9, revision 155196, in 32 bit mode, but not in the 64 bit one. The compilation goes fine on x86_64-apple-darwin10, revision 155224.
Comment 5 Richard Biener 2009-12-15 13:50:35 UTC
I can reproduce it with the testcase in comment #1 on i?86-linux:

$ ./f951  -quiet t.f -O2 -floop-strip-mine -fprefetch-loop-arrays -msse2
t.f: In function 'blts':
t.f:1:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Program received signal SIGSEGV, Segmentation fault.
0x086197d5 in initialize_matrix_A (A=0xb778ecb0, chrec=0xb77d36e4, index=2, 
    mult=-1) at /home/richard/src/trunk/gcc/tree-data-ref.c:1914
1914	      A[index][0] = mult * int_cst_value (CHREC_RIGHT (chrec));
(gdb) p A[index]
$4 = (lambda_vector) 0x6
Comment 6 Richard Biener 2009-12-15 13:51:41 UTC
Works for me with 4.4.2 on i?86-linux.
Comment 7 Janis Johnson 2010-01-07 22:07:17 UTC
I still see both failures with -m32 on powerpc64-linux but not with -m64.
Comment 8 Janis Johnson 2010-02-23 21:17:41 UTC
With today's trunk both testcases fail with -m32 but not -m64.  sixtrack builds, but not applu.
Comment 9 p.vanhoof@oma.be 2010-02-27 13:53:52 UTC
The following Lagrange interpolation routine crashes the trunk

> gcc -O1 -floop-parallelize-all -c bug.c
bug.c: In function ‘lagrange’:
bug.c:1:8: internal compiler error: Segmentation fault
... etc.

> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/common/compilers/gcc450/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-mainline/configure --prefix=/usr/local/gcc450 --enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.5.0 20100226 (experimental) (GCC)

This is r157083 of the trunk.

> cat bug.c
double lagrange(const double x[],
                const double y[],
                long n,
                double xval)
{
        long i, j;
        double yval = 0.;

        for( i=0; i < n; i++ )
        {
                double l = 1.;
                for( j=0; j < n; j++ )
                        if( i != j )
                                l *= (xval-x[j])/(x[i]-x[j]);
                yval += y[i]*l;
        }
        return yval;
}

The same problem?
Comment 10 Sebastian Pop 2010-03-02 11:39:11 UTC
Comment #9 is not the same as the original reported bug.
I have a fix for #9.

Sebastian
Comment 11 Sebastian Pop 2010-03-02 11:51:48 UTC
Subject: Bug 42326

Author: spop
Date: Tue Mar  2 11:51:21 2010
New Revision: 157162

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157162
Log:
Fix PR42326: handle default definitions.

2010-03-02  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/42326
	* sese.c (name_defined_in_loop_p): Return false for default
	definitions.

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

Added:
    branches/graphite/gcc/testsuite/gcc.dg/graphite/pr42326.c
Modified:
    branches/graphite/gcc/ChangeLog.graphite
    branches/graphite/gcc/sese.c

Comment 12 Sebastian Pop 2010-03-04 22:27:15 UTC
We are building scalar evolutions that have no defined semantics:
the initial value is variating in an inner loop.

{(2 + (integer(kind=4)) {0, +, 1}_5) * 5 + ((2 + (integer(kind=4)) {0, +, 1}_4) + -6), +, 6}_1
and
{(2 + (integer(kind=4)) {0, +, 1}_5) * 5 + -5, +, 6}_1

in the following loop nest:

(gdb) p debug_loops (1)
loop_0 (header = 0, latch = 1, niter = )
{
  loop_1 (header = 3, latch = 14, niter = , upper_bound = 4, estimate = 4)
  {
    loop_4 (header = 6, latch = 11, niter = , upper_bound = 4294967296)
    {
      loop_5 (header = 8, latch = 9, niter = D.1652_117, upper_bound = 4294967296)
      {
      }
    }
  }
}

Comment 13 Sebastian Pop 2010-03-05 09:39:20 UTC
We build these scevs because chrec_fold_multiply and chrec_fold_plus
do not correctly handle conversions:  op0 = (integer(kind=4)) {0, +, 1}_4
is considered non variating in any loop, and thus when op0 gets added to
op1 = {0, +, 1}_1, the result is: {(integer(kind=4)) {0, +, 1}_4, +, 1}_1 that
has no defined semantics.
Comment 14 Sebastian Pop 2010-03-05 12:20:53 UTC
Patch at http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00237.html
Comment 15 Sebastian Pop 2010-03-05 20:38:15 UTC
Subject: Bug 42326

Author: spop
Date: Fri Mar  5 20:37:44 2010
New Revision: 157244

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157244
Log:
Fix PR42326: Handle more carefully convert expressions in chrec_fold_plus and chrec_fold_mult.

2010-03-05  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/42326
	* tree-chrec.c (chrec_fold_plus_1): Do not handle convert expressions
	that contain scevs.
	(chrec_fold_multiply): Same.

	* gfortran.dg/graphite/pr42326.f90: New.
	* gfortran.dg/graphite/pr42326-1.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/graphite/pr42326-1.f90
    trunk/gcc/testsuite/gfortran.dg/graphite/pr42326.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-chrec.c

Comment 16 Sebastian Pop 2010-03-05 20:39:12 UTC
Fixed.
Comment 17 p.vanhoof@oma.be 2010-03-07 14:12:18 UTC
The test case in comment #9 has only been fixed on the graphite branch, but still crashes on the trunk as of r157255. Please reopen and fix this problem on the trunk.
Comment 18 H.J. Lu 2010-03-07 14:43:25 UTC
Confirmed. This patch:

Fix PR42326: handle default definitions.

2010-03-02  Sebastian Pop  <sebastian.pop@amd.com>

        PR middle-end/42326
        * sese.c (name_defined_in_loop_p): Return false for default
        definitions.

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

Added:
    branches/graphite/gcc/testsuite/gcc.dg/graphite/pr42326.c
Modified:
    branches/graphite/gcc/ChangeLog.graphite
    branches/graphite/gcc/sese.c

isn't in trunk.
Comment 19 Sebastian Pop 2010-03-08 17:49:15 UTC
Subject: Bug 42326

Author: spop
Date: Mon Mar  8 17:48:55 2010
New Revision: 157280

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157280
Log:
Fix PR42326: handle default definitions.

2010-03-02  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/42326
	* sese.c (name_defined_in_loop_p): Return false for default
	definitions.

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

Added:
    trunk/gcc/testsuite/gcc.dg/graphite/pr42326.c
Modified:
    trunk/gcc/ChangeLog.graphite
    trunk/gcc/sese.c

Comment 20 Sebastian Pop 2010-03-08 17:51:53 UTC
Fixed now the second unrelated bug reported within this PR.