Bug 81500 - [8 Regression] ICE with -O3 in process_use, at tree-vect-stmts.c:506
Summary: [8 Regression] ICE with -O3 in process_use, at tree-vect-stmts.c:506
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-07-20 20:37 UTC by David Binderman
Modified: 2017-07-21 11:32 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-07-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2017-07-20 20:37:51 UTC
The following code, when compiled by recent gcc trunk and flag -O3, does this:

/home/dcb/creduce/dcbTest/bug369.c:2:1: internal compiler error: in process_use, at tree-vect-stmts.c:506
 c(b) {
 ^
0xeddbb0 process_use
	../../trunk/gcc/tree-vect-stmts.c:505
0xede01d vect_mark_stmts_to_be_vectorized(_loop_vec_info*)
	../../trunk/gcc/tree-vect-stmts.c:789
0xf0722d vect_analyze_loop_2
	../../trunk/gcc/tree-vect-loop.c:1950
0xf0722d vect_analyze_loop(loop*, _loop_vec_info*)
	../../trunk/gcc/tree-vect-loop.c:2405

Source is

typedef a;
c(b) {
  int d;
  a e, f, *g, *h = b;
  for (; d; d--) {
    f = *g & 1;
    *h-- = *g-- | e;
    e = f;
  }
}

Problem seems to exist between gcc revisions 250361 and 250395.

Looking at recent changes to source code file tree-vect-stmt.c,
Richard Biener's revision 250382 looks a likely candidate.
Comment 1 Martin Liška 2017-07-21 07:55:08 UTC
Confirmed, started with r250382.
Comment 2 Richard Biener 2017-07-21 08:59:03 UTC
Mine.
Comment 3 David Binderman 2017-07-21 09:22:24 UTC
Possible duplicate for this reduced code:

struct a {
  int b;
  int c
};
struct d {
  struct a *e
} f(struct d *g) {
  int h;
  int b;
  for (; h; ++h) {
    int i = g->e[h].c + 1;
    g->e[h].c = g->e[h].b;
    g->e[h].b = b;
    b = i;
  }
  if (b)
    j();
}

$ ~/gcc/results/bin/gcc -c -O3 -w bug370.c
during GIMPLE pass: vect
bug370.c: In function ‘f’:
bug370.c:7:3: internal compiler error: in vect_analyze_stmt, at tree-vect-stmts.c:8524
 } f(struct d *g) {
   ^
0xef7559 vect_analyze_stmt(gimple*, bool*, _slp_tree*, _slp_instance*)
	../../trunk/gcc/tree-vect-stmts.c:8519
0xf1217a vect_slp_analyze_node_operations
	../../trunk/gcc/tree-vect-slp.c:2510
0xf12075 vect_slp_analyze_node_operations
	../../trunk/gcc/tree-vect-slp.c:2453
0xf175ef vect_slp_analyze_operations(vec<_slp_instance*, va_heap, vl_ptr>, void*)
Comment 4 rguenther@suse.de 2017-07-21 09:36:38 UTC
On Fri, 21 Jul 2017, dcb314 at hotmail dot com wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81500
> 
> --- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
> Possible duplicate for this reduced code:
> 
> struct a {
>   int b;
>   int c
> };
> struct d {
>   struct a *e
> } f(struct d *g) {
>   int h;
>   int b;
>   for (; h; ++h) {
>     int i = g->e[h].c + 1;
>     g->e[h].c = g->e[h].b;
>     g->e[h].b = b;
>     b = i;
>   }
>   if (b)
>     j();
> }

Yeah.  Fix is obvious:

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c        (revision 250386)
+++ gcc/tree-vect-loop.c        (working copy)
@@ -3243,7 +3243,7 @@ pop:
     }
 
   /* Check whether the reduction path detected is valid.  */
-  bool fail = false;
+  bool fail = path.length () == 0;
   bool neg = false;
   for (unsigned i = 1; i < path.length (); ++i)
     {
@@ -3276,9 +3276,7 @@ pop:
 
   if (dump_enabled_p ())
     {
-      report_vect_op (MSG_MISSED_OPTIMIZATION,
-                     SSA_NAME_DEF_STMT
-                       (USE_FROM_PTR (path[path.length ()-1].second)),
+      report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
                      "reduction: unknown pattern: ");
     }
Comment 5 Richard Biener 2017-07-21 11:32:33 UTC
Author: rguenth
Date: Fri Jul 21 11:32:01 2017
New Revision: 250423

URL: https://gcc.gnu.org/viewcvs?rev=250423&root=gcc&view=rev
Log:
2017-06-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/81500
	* tree-vect-loop.c (vect_is_simple_reduction): Properly fail if
	we didn't identify a reduction path.

	* gcc.dg/torture/pr81500.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr81500.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vect-loop.c
Comment 6 Richard Biener 2017-07-21 11:32:52 UTC
Fixed.