Bug 37174 - [4.4 Regression] ICE: in vinfo_for_stmt, at tree-vectorizer.h:546
Summary: [4.4 Regression] ICE: in vinfo_for_stmt, at tree-vectorizer.h:546
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.4.0
: P1 normal
Target Milestone: 4.4.0
Assignee: Ira Rosen
URL:
Keywords: ice-on-valid-code
: 37198 37209 (view as bug list)
Depends on:
Blocks: 29975
  Show dependency treegraph
 
Reported: 2008-08-20 07:35 UTC by Joost VandeVondele
Modified: 2008-08-23 11:41 UTC (History)
5 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-08-20 09:49:21


Attachments
testcase (160.74 KB, application/octet-stream)
2008-08-20 07:36 UTC, Joost VandeVondele
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2008-08-20 07:35:09 UTC
this night's trunk breaks building CP2K, testcase to be attached:

> gfortran -c -O3 -ffast-math -funroll-loops -ftree-vectorize -march=native -v bug.f90
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /data/vondele/gcc_bench/gcc_trunk/gcc/configure --prefix=/data/vondele/gcc_bench/gcc_trunk/build --enable-languages=c,fortran
Thread model: posix
gcc version 4.4.0 20080819 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-c' '-O3' '-ffast-math' '-funroll-loops' '-ftree-vectorize'  '-v'
 /data/vondele/gcc_bench/gcc_trunk/build/libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/f951 bug.f90 -march=core2 -mcx16 -msahf --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=core2 -quiet -dumpbase bug.f90 -auxbase bug -O3 -version -ffast-math -funroll-loops -ftree-vectorize -fintrinsic-modules-path /data/vondele/gcc_bench/gcc_trunk/build/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/finclude -o /tmp/ccNb5Smz.s
GNU Fortran (GCC) version 4.4.0 20080819 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.0 20080819 (experimental), GMP version 4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
bug.f90: In function ‘nmr_shift_print’:
bug.f90:121: internal compiler error: in vinfo_for_stmt, at tree-vectorizer.h:546
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

most likely due to '2008-08-19  Ira Rosen  <irar@il.ibm.com>'
Comment 1 Joost VandeVondele 2008-08-20 07:36:56 UTC
Created attachment 16105 [details]
testcase
Comment 2 Wouter Vermaelen 2008-08-20 09:38:57 UTC
I can trigger the same ICE with this testcase:

---------------------------------------------------
int* getFoo();
struct Bar {
        Bar();
        int* foo1;
        int* foo2;
        int* table[4][4][4];
};
Bar::Bar() {
        foo1 = getFoo();
        foo2 = getFoo();
        for (int a = 0; a < 4; ++a) {
                for (int b = 0; b < 4; ++b) {
                        for (int c = 0; c < 4; ++c) {
                                table[a][b][c] = foo1;
                        }
                }
        }
}
--------------------------------------------------------

compile with:
  g++ -O3 bug.ii
Comment 3 Wouter Vermaelen 2008-08-20 10:43:51 UTC
I can confirm, SVN revision trunk@139225 is the first one with this bug.
Comment 4 Ira Rosen 2008-08-20 12:18:38 UTC
I am testing the following patch:

Index: tree-vect-analyze.c
===================================================================
--- tree-vect-analyze.c (revision 139225)
+++ tree-vect-analyze.c (working copy)
@@ -2531,7 +2535,7 @@ vect_get_and_check_slp_defs (loop_vec_in
       /* Check if DEF_STMT is a part of a pattern and get the def stmt from
          the pattern. Check that all the stmts of the node are in the
          pattern.  */
-      if (def_stmt && vinfo_for_stmt (def_stmt)
+      if (def_stmt && dt[i] == vect_loop_def && vinfo_for_stmt (def_stmt)
           && STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (def_stmt)))
         {
           if (!*first_stmt_dt0)

If everything goes OK, I will submit it tomorrow.

Comment 5 Joost VandeVondele 2008-08-20 12:34:04 UTC
(In reply to comment #4)
> I am testing the following patch:

I checked that it fixed the problem with the original bug (PR37174.tgz)

Thanks!

> 
> Index: tree-vect-analyze.c
> ===================================================================
> --- tree-vect-analyze.c (revision 139225)
> +++ tree-vect-analyze.c (working copy)
> @@ -2531,7 +2535,7 @@ vect_get_and_check_slp_defs (loop_vec_in
>        /* Check if DEF_STMT is a part of a pattern and get the def stmt from
>           the pattern. Check that all the stmts of the node are in the
>           pattern.  */
> -      if (def_stmt && vinfo_for_stmt (def_stmt)
> +      if (def_stmt && dt[i] == vect_loop_def && vinfo_for_stmt (def_stmt)
>            && STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (def_stmt)))
>          {
>            if (!*first_stmt_dt0)
> 
> If everything goes OK, I will submit it tomorrow.
> 

Comment 6 Richard Biener 2008-08-22 09:57:32 UTC
*** Bug 37198 has been marked as a duplicate of this bug. ***
Comment 7 irar 2008-08-23 10:43:44 UTC
Subject: Bug 37174

Author: irar
Date: Sat Aug 23 10:42:34 2008
New Revision: 139508

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139508
Log:
	PR tree-optimization/37174
	* tree-vect-analyze.c (vect_get_and_check_slp_defs): Check that the
	def stmt is a part of the loop before accessing its stmt_vec_info.


Added:
    trunk/gcc/testsuite/g++.dg/vect/pr37174.cc
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-analyze.c

Comment 8 Ira Rosen 2008-08-23 11:32:55 UTC
Fixed.
Comment 9 Tobias Burnus 2008-08-23 11:41:42 UTC
*** Bug 37209 has been marked as a duplicate of this bug. ***