Bug 36922 - [4.4 Regression] ICE in tree-data-ref.c with -ftree-loop-linear
Summary: [4.4 Regression] ICE in tree-data-ref.c with -ftree-loop-linear
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P2 normal
Target Milestone: 4.4.0
Assignee: Sebastian Pop
URL:
Keywords: ice-on-valid-code
: 37007 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-24 20:43 UTC by Pat Haugen
Modified: 2009-02-17 23:37 UTC (History)
4 users (show)

See Also:
Host: powerpc64-linux
Target: powerpc64-linux
Build: powerpc64-linux
Known to work:
Known to fail:
Last reconfirmed: 2008-11-04 01:03:25


Attachments
gcc44-pr36922.patch (1.07 KB, patch)
2009-02-17 17:38 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pat Haugen 2008-07-24 20:43:53 UTC
Current trunk is ICE'ing when trying to build CPU2006 benchmark 416.gamess with -ftree-loop-linear.

run/build_base_gcc_64.0001> cat junk.f
      SUBROUTINE GETCOF2(NP,FLM,ZLL,COEFF)
C
      IMPLICIT DOUBLE PRECISION(A-H,O-Z)
      PARAMETER (MAXCOF=23821)
      DIMENSION COEFF(MAXCOF),
     *          ZLL(0:2*NP+1),FLM(0:2*NP)
C
      LENG=0
      DO L=0,NP
         DO M=0,L
            DO LK=M,L
               LENG=LENG+1
               COEFF(LENG)=FLM(L+M)*FLM(L-M)*ZLL(L-LK)/(FLM(LK+M)*
     *             FLM(LK-M)*FLM(L-LK)*FLM(L-LK))
            ENDDO
         ENDDO
      ENDDO
C
      RETURN
      END

run/build_base_gcc_64.0001> /home/pthaugen/install/gcc/trunk/bin/gfortran -c -O2 -ftree-loop-linear junk.f
junk.f: In function 'getcof2':
junk.f:1: internal compiler error: in initialize_matrix_A, at tree-data-ref.c:1885
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Paolo Carlini 2008-08-02 03:49:18 UTC
*** Bug 37007 has been marked as a duplicate of this bug. ***
Comment 2 Richard Biener 2008-08-02 11:50:13 UTC
Confirmed by the dup.
Comment 3 David Edelsohn 2008-08-04 21:57:53 UTC
Copying from the duplicate PR...

The failure starts with this patch:

   http://gcc.gnu.org/viewcvs?view=rev&rev=135116

    r135116 | spop | 2008-05-09 16:17:47 +0000 (Fri, 09 May 2008)
Comment 4 Jakub Jelinek 2008-09-15 16:49:30 UTC
The ICE is because initialize_matrix_A doesn't expect to see BIT_NOT_EXPR,
which is created by fold:
"Convert -1 - A to ~A." and "Convert -A - 1 to ~A." cases.
I've tried to handle that:
@@ -1896,6 +1896,15 @@ initialize_matrix_A (lambda_matrix A, tr
     case INTEGER_CST:
       return chrec;
 
+    /* -1 - A is folded into ~A.  */
+    case BIT_NOT_EXPR:
+      {
+        tree op1 = initialize_matrix_A (A, TREE_OPERAND (chrec, 0), index, mult);
+
+        return chrec_fold_op (MINUS_EXPR, chrec_type (chrec),
+                              build_int_cst (TREE_TYPE (chrec), -1), op1);
+      }
+
     default:
       gcc_unreachable ();
       return NULL_TREE;

but unfortunately that doesn't get us very far.
analyze_subscript_affine_affine is called with:
chrec_a: {0, +, 1}_3
chrec_b: {{(integer(kind=8)) ~{0, +, 1}_2, +, 1}_1, +, -1}_3
where nb_vars_a is (probably correctly) 1, but nb_vars_b is just 2, so it tries to write to *A[3], which is uninitialized.  Guess more places would need to handle BIT_NOT_EXPR, or alternatively scev needs to ensure fold doesn't fold -1 - A into ~A (or undo that folding).
Comment 5 Jakub Jelinek 2008-11-03 17:22:52 UTC
Sebastian, any ideas how to fix this one?
Comment 6 Sebastian Pop 2008-11-04 01:03:24 UTC
Mine.
Comment 7 Sebastian Pop 2008-11-04 01:03:30 UTC
Subject: Re:  [4.4 Regression] ICE in tree-data-ref.c with -ftree-loop-linear

> Sebastian, any ideas how to fix this one?

I will look at this bug.
Comment 8 Jakub Jelinek 2008-12-08 14:00:44 UTC
Any news on this?
Comment 9 Janis Johnson 2009-01-08 18:08:34 UTC
I tried the submitter's testcase on i686-pc-linux-gnu using trunk revision 143188 (today) and got the same ICE:

laptop% /home/janis/tools/gcc-trunk-bid/bin/gfortran -c -O2 -ftree-loop-linear 36922.f
36922.f: In function ‘getcof2’:
36922.f:1: internal compiler error: in initialize_matrix_A, at tree-data-ref.c:1903
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

This isn't specific to powerpc.
Comment 10 Jakub Jelinek 2009-02-17 17:38:54 UTC
Created attachment 17312 [details]
gcc44-pr36922.patch

Patch that fixes this for me.  I'm going to bootstrap/regtest it now.
Comment 11 Jakub Jelinek 2009-02-17 23:21:39 UTC
Subject: Bug 36922

Author: jakub
Date: Tue Feb 17 23:21:23 2009
New Revision: 144250

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144250
Log:
	PR tree-optimization/36922
	* tree-data-ref.c (initialize_matrix_A): Handle BIT_NOT_EXPR.
	* tree-scalar-evolution.c (interpret_rhs_expr, instantiate_scev_1):
	Likewise.

	* gfortran.dg/pr36922.f: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr36922.f
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-data-ref.c
    trunk/gcc/tree-scalar-evolution.c

Comment 12 Jakub Jelinek 2009-02-17 23:37:57 UTC
Fixed.