Bug 32417 - [4.3 Regression] 416.gamess ICEs (in aff_combination_add_elt, tree-affine.c)
Summary: [4.3 Regression] 416.gamess ICEs (in aff_combination_add_elt, tree-affine.c)
Status: RESOLVED DUPLICATE of bug 32527
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Andrew Pinski
URL:
Keywords: ice-on-valid-code
: 32459 32478 (view as bug list)
Depends on:
Blocks: 29975
  Show dependency treegraph
 
Reported: 2007-06-20 13:19 UTC by Richard Biener
Modified: 2007-07-02 23:59 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-06-22 00:22:36


Attachments
testcase (468 bytes, text/plain)
2007-06-20 13:20 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2007-06-20 13:19:08 UTC
/gcc/spec/sb-balakirew-head-64-2006/x86_64/install-hack/bin/gfortran -c -o nmr.fppized.o    -O2       -DSPEC_CPU_LP64  -ffixed-form       nmr.fppized.f
nmr.fppized.f: In function 'oneints':
nmr.fppized.f:617: internal compiler error: in build2_stat, at tree.c:3074
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Richard Biener 2007-06-20 13:20:58 UTC
Created attachment 13741 [details]
testcase

Testcase that fails with -O2 -ffixed-form
Comment 2 Richard Biener 2007-06-20 13:21:58 UTC
#0  fancy_abort (
    file=0xe87fc8 "/space/rguenther/src/svn/pointer_plus/gcc/tree.c", 
    line=3074, function=0xe893df "build2_stat")
    at /space/rguenther/src/svn/pointer_plus/gcc/diagnostic.c:656
#1  0x0000000000a28c7e in build2_stat (code=MULT_EXPR, tt=0x2ab8fd777600, 
    arg0=0x2ab8fe1bc8c0, arg1=0x2ab8fe1acb70)
    at /space/rguenther/src/svn/pointer_plus/gcc/tree.c:3074
#2  0x00000000006b4c2b in fold_build2_stat (code=MULT_EXPR, 
    type=0x2ab8fd777600, op0=0x2ab8fe1bc8c0, op1=0x2ab8fe1acb70)
    at /space/rguenther/src/svn/pointer_plus/gcc/fold-const.c:12943
#3  0x0000000000d5df39 in aff_combination_add_elt (comb=0x7fffad3af9f0, 
    elt=0x2ab8fe137840, scale={low = 4, high = 0})
    at /space/rguenther/src/svn/pointer_plus/gcc/tree-affine.c:175
Comment 3 Andrew Pinski 2007-06-22 00:22:36 UTC
Reduced testcase:
      SUBROUTINE ONEINTS()
      COMMON /INFOA / NAT,NUM
      DIMENSION TINT(NUM*NUM,NAT,3,3,3),TINTM(NUM,NUM,NAT,3,3,3)

        CALL TINTS(IC)
        DO ID=1,3
        DO IC=1,NAT
           TINTM(J,I,IC,IAN,INU,ID) = TINT((I-1)*NUM+J,IC,IAN,INU,ID)
        ENDDO
        ENDDO
      END

Comment 4 Andrew Pinski 2007-06-22 00:36:03 UTC
Here is the patch which fixes this testcase (note IV-OPTS is still messed up but I will work on that later):
Index: tree-affine.c
===================================================================
--- tree-affine.c       (revision 125927)
+++ tree-affine.c       (working copy)
@@ -130,6 +130,7 @@
 aff_combination_add_elt (aff_tree *comb, tree elt, double_int scale)
 {
   unsigned i;
+  tree type;
 
   scale = double_int_ext_for_comb (scale, comb);
   if (double_int_zero_p (scale))
@@ -169,17 +170,26 @@
       return;
     }
 
+  type = comb->type;
+  if (POINTER_TYPE_P (type))
+    type = sizetype;
+
   if (double_int_one_p (scale))
-    elt = fold_convert (comb->type, elt);
+    elt = fold_convert (type, elt);
   else
-    elt = fold_build2 (MULT_EXPR, comb->type,
-                      fold_convert (comb->type, elt),
-                      double_int_to_tree (comb->type, scale)); 
+    elt = fold_build2 (MULT_EXPR, type,
+                      fold_convert (type, elt),
+                      double_int_to_tree (type, scale)); 
 
   if (comb->rest)
-    comb->rest = fold_build2 (PLUS_EXPR, comb->type, comb->rest, elt);
+    {
+      if (!POINTER_TYPE_P (comb->type))
+       comb->rest = fold_build2 (PLUS_EXPR, comb->type, comb->rest, elt);
+      else
+       comb->rest = fold_build2 (POINTER_PLUS_EXPR, comb->type, comb->rest, elt);
+    }
   else
-    comb->rest = elt;
+    comb->rest = fold_convert (comb->type, elt);
 }
 
 /* Adds CST to C.  */
Comment 5 Richard Biener 2007-06-22 19:48:10 UTC
*** Bug 32459 has been marked as a duplicate of this bug. ***
Comment 6 Andrew Pinski 2007-06-24 10:51:05 UTC
*** Bug 32478 has been marked as a duplicate of this bug. ***
Comment 7 Andrew Pinski 2007-06-26 22:08:11 UTC
Patch testing right now.
Comment 8 Andrew Pinski 2007-06-28 19:04:08 UTC
Subject: Bug 32417

Author: pinskia
Date: Thu Jun 28 19:03:49 2007
New Revision: 126082

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=126082
Log:
2007-06-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/32417
        * tree-affine.c (aff_combination_add_elt): Handle
        pointer addition specially.

2007-06-28  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/32417
        * gfortran.fortran-torture/compile/pr32417.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.fortran-torture/compile/pr32417.f90
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-affine.c

Comment 9 Andrew Pinski 2007-06-28 19:06:26 UTC
Fixed.
Comment 10 Richard Biener 2007-07-02 10:49:17 UTC
The testcase still fails for me at -O2.

./f951 -quiet -O2 nmr.min.f 
nmr.min.f: In function 'oneints':
nmr.min.f:1: internal compiler error: in build2_stat, at tree.c:3074
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 11 Richard Biener 2007-07-02 11:41:47 UTC
In fact I see

 FAIL: gfortran.fortran-torture/compile/pr32417.f90,  "-O"   (internal compiler error)

on i686-pc-linux-gnu.
Comment 12 Andrew Pinski 2007-07-02 23:58:01 UTC
One note, when I was originally fixing this bug, the test worked but now it fails at -O1.  I guess the new VN exposed the new problem.
Comment 13 Andrew Pinski 2007-07-02 23:59:21 UTC
Ok, the problem at -O1 is really PR 32527.

So I am closing this as a dup of that bug.

*** This bug has been marked as a duplicate of 32527 ***
Comment 14 rguenther@suse.de 2007-07-03 10:55:14 UTC
Subject: Re:  [4.3 Regression] 416.gamess ICEs (in
 aff_combination_add_elt, tree-affine.c)

On Tue, 2 Jul 2007, pinskia at gcc dot gnu dot org wrote:

> ------- Comment #12 from pinskia at gcc dot gnu dot org  2007-07-02 23:58 -------
> One note, when I was originally fixing this bug, the test worked but now it
> fails at -O1.  I guess the new VN exposed the new problem.

gamess didn't get back to working, but maybe the reduced testcase was
indeed fixed for some time.

Richard.