Bug 40074 - [4.4/4.5 Regression] ICE in vect_get_vec_def_for_operand, at tree-vect-stmts.c:944
Summary: [4.4/4.5 Regression] ICE in vect_get_vec_def_for_operand, at tree-vect-stmts....
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.1
Assignee: Ira Rosen
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-05-08 20:15 UTC by ronis
Modified: 2009-05-11 12:45 UTC (History)
3 users (show)

See Also:
Host:
Target: i686-linux-gnu
Build:
Known to work: 4.3.3
Known to fail: 4.4.0
Last reconfirmed: 2009-05-10 11:00:34


Attachments
Preprocessed source of source that triggers ICE (33.40 KB, application/octet-stream)
2009-05-08 20:16 UTC, ronis
Details
reduced testcase (852 bytes, text/plain)
2009-05-08 21:00 UTC, Richard Biener
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ronis 2009-05-08 20:15:53 UTC
I;m running gcc-4.4.0 (built with default optimization flags, but with additional optimizations) and was testing it on ocrad-0.18 (admittedly with lots of optimization):  I get


g++  -march=pentium4 -msse2 -mfpmath=sse -O3 -ffast-math -funroll-loops -fomit-frame-pointer -floop-interchange -floop-strip-mine -floop-block -c -o track.o track.cc
track.cc: In member function 'void Track::set_track(const std::vector<Rectangle, std::allocator<Rectangle> >&)':
track.cc:219: internal compiler error: in vect_get_vec_def_for_operand, at tree-vect-transform.c:1999

I'll attach the preprocessed source separately.
Comment 1 ronis 2009-05-08 20:16:45 UTC
Created attachment 17832 [details]
Preprocessed source of source that triggers ICE
Comment 2 Richard Biener 2009-05-08 20:41:41 UTC
Reducing.
Comment 3 Richard Biener 2009-05-08 20:59:57 UTC
Confirmed.
Comment 4 Richard Biener 2009-05-08 21:00:20 UTC
Created attachment 17833 [details]
reduced testcase
Comment 5 H.J. Lu 2009-05-09 22:02:30 UTC
This is caused by revision 145494:

http://gcc.gnu.org/ml/gcc-cvs/2009-04/msg00115.html
Comment 6 Richard Biener 2009-05-09 22:10:58 UTC
How can that be if the bug also happens on the 4.4 branch?
Comment 7 H.J. Lu 2009-05-09 22:15:11 UTC
(In reply to comment #6)
> How can that be if the bug also happens on the 4.4 branch?
> 

The testcase in comment #4 compiles fine with gcc 4.4.1.
Comment 8 H.J. Lu 2009-05-09 22:31:12 UTC
(In reply to comment #1)
> Created an attachment (id=17832) [edit]
> Preprocessed source of source that triggers ICE
> 

This was introduced between revisions 138059 and 13934.
Comment 9 Jakub Jelinek 2009-05-09 22:54:52 UTC
The original testcase failure fails with both 4.4.x and trunk and was introduced between 138524 and 138811.  The reduced testcase only fails on the trunk, not on the 4.4 branch.
Comment 10 Jakub Jelinek 2009-05-10 00:08:45 UTC
r138553 in particular.  -O2 -ftree-vectorize -m32 -msse2 is needed to reproduce it.
Comment 11 H.J. Lu 2009-05-10 00:23:20 UTC
It is caused by revision 138553:

http://gcc.gnu.org/ml/gcc-cvs/2008-08/msg00112.html
Comment 12 Richard Biener 2009-05-10 09:14:53 UTC
Well, that revision only enabled vectorization support for more things...
(which is probably what makes this a regression in the first place).
Comment 13 Ira Rosen 2009-05-10 09:20:46 UTC
(In reply to comment #12)
> Well, that revision only enabled vectorization support for more things...
> (which is probably what makes this a regression in the first place).

Right, I think it is something in the strided accesses detection. I am looking into it now.
Comment 14 Ira Rosen 2009-05-10 11:00:33 UTC
I am testing:

Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c       (revision 147329)
+++ tree-vect-data-refs.c       (working copy)
@@ -1424,7 +1424,7 @@ vect_analyze_group_access (struct data_r
       /* First stmt in the interleaving chain. Check the chain.  */
       gimple next = DR_GROUP_NEXT_DR (vinfo_for_stmt (stmt));
       struct data_reference *data_ref = dr;
-      unsigned int count = 1;
+      unsigned int count = 1, gaps = 0;
       tree next_step;
       tree prev_init = DR_INIT (data_ref);
       gimple prev = stmt;
@@ -1490,6 +1490,8 @@ vect_analyze_group_access (struct data_r
                    fprintf (vect_dump, "interleaved store with gaps");
                  return false;
                }
+
+              gaps += diff - 1;
            }

           /* Store the gap from the previous member of the group. If there is no
@@ -1506,8 +1508,9 @@ vect_analyze_group_access (struct data_r
          the type to get COUNT_IN_BYTES.  */
       count_in_bytes = type_size * count;

-      /* Check that the size of the interleaving is not greater than STEP.  */
-      if (dr_step < count_in_bytes)
+     /* Check that the size of the interleaving (including gaps) is not greater
+         than STEP.  */
+      if (dr_step && dr_step < count_in_bytes + gaps * type_size)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {

It fixes the reduced testcase, but I failed to compile the original one, so maybe someone could check that the above patch fixes the ICE for the original testcase?

Thanks,
Ira
Comment 15 H.J. Lu 2009-05-10 16:11:55 UTC
(In reply to comment #14)
> I am testing:
> 
> Index: tree-vect-data-refs.c
> ===================================================================
> --- tree-vect-data-refs.c       (revision 147329)
> +++ tree-vect-data-refs.c       (working copy)
> @@ -1424,7 +1424,7 @@ vect_analyze_group_access (struct data_r
>        /* First stmt in the interleaving chain. Check the chain.  */
>        gimple next = DR_GROUP_NEXT_DR (vinfo_for_stmt (stmt));
>        struct data_reference *data_ref = dr;
> -      unsigned int count = 1;
> +      unsigned int count = 1, gaps = 0;
>        tree next_step;
>        tree prev_init = DR_INIT (data_ref);
>        gimple prev = stmt;
> @@ -1490,6 +1490,8 @@ vect_analyze_group_access (struct data_r
>                     fprintf (vect_dump, "interleaved store with gaps");
>                   return false;
>                 }
> +
> +              gaps += diff - 1;
>             }
> 
>            /* Store the gap from the previous member of the group. If there is
> no
> @@ -1506,8 +1508,9 @@ vect_analyze_group_access (struct data_r
>           the type to get COUNT_IN_BYTES.  */
>        count_in_bytes = type_size * count;
> 
> -      /* Check that the size of the interleaving is not greater than STEP.  */
> -      if (dr_step < count_in_bytes)
> +     /* Check that the size of the interleaving (including gaps) is not
> greater
> +         than STEP.  */
> +      if (dr_step && dr_step < count_in_bytes + gaps * type_size)
>          {
>            if (vect_print_dump_info (REPORT_DETAILS))
>              {
> 
> It fixes the reduced testcase, but I failed to compile the original one, so
> maybe someone could check that the above patch fixes the ICE for the original
> testcase?
> 

It fixed the original testcase on 4.4 branch.

Comment 16 irar 2009-05-11 11:54:16 UTC
Subject: Bug 40074

Author: irar
Date: Mon May 11 11:54:02 2009
New Revision: 147370

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147370
Log:
	PR tree-optimization/40074
	* tree-vect-analyze.c (vect_analyze_group_access): Take gaps into
	account in group size and step comparison.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr40074.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/tree-vect-analyze.c

Comment 17 irar 2009-05-11 12:33:35 UTC
Subject: Bug 40074

Author: irar
Date: Mon May 11 12:33:13 2009
New Revision: 147372

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147372
Log:
	PR tree-optimization/40074
	* tree-vect-data-refs.c (vect_analyze_group_access): Take gaps into
	account in group size and step comparison.


Added:
    trunk/gcc/testsuite/gcc.dg/vect/pr40074.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-data-refs.c

Comment 18 Ira Rosen 2009-05-11 12:45:21 UTC
Fixed.