re PR tree-optimization/83867 (ICE: Segmentation fault in nested_in_vect_loop_p)
authorRichard Biener <rguenther@suse.de>
Tue, 16 Jan 2018 15:13:05 +0000 (15:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 16 Jan 2018 15:13:05 +0000 (15:13 +0000)
2018-01-16  Richard Biener  <rguenther@suse.de>

PR tree-optimization/83867
* tree-vect-stmts.c (vect_transform_stmt): Precompute
nested_in_vect_loop_p since the scalar stmt may get invalidated.

* gcc.dg/vect/pr83867.c: New testcase.

From-SVN: r256746

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr83867.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 9b7bf83cb770fd1c5df90fc9a9be5424f0f3f3e9..055e924a8b0bf6a5827c6afeb9f71182c1ff2ff7 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/83867
+       * tree-vect-stmts.c (vect_transform_stmt): Precompute
+       nested_in_vect_loop_p since the scalar stmt may get invalidated.
+
 2018-01-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/83844
index ec9f4695cc315c7695b62f98948c48f3240a01be..ae578285db08874236b6e1670a1a8fbbd040502c 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-16  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/83867
+       * gcc.dg/vect/pr83867.c: New testcase.
+
 2018-01-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/83844
diff --git a/gcc/testsuite/gcc.dg/vect/pr83867.c b/gcc/testsuite/gcc.dg/vect/pr83867.c
new file mode 100644 (file)
index 0000000..aab5bb7
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O -ftrapv" } */
+
+int
+k5 (int u5, int aw)
+{
+  int v6;
+
+  while (u5 < 1)
+    {
+      while (v6 < 4)
+       ++v6;
+
+      v6 = 0;
+      aw += u5 > 0;
+      ++u5;
+    }
+
+  return aw;
+}
index 0f74772fe7e16964c8c04a5b49b966dd0e3b5173..3f8eb9242a34994d1c6d9292cda711ce82c2bd87 100644 (file)
@@ -9426,6 +9426,11 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi,
   gcc_assert (slp_node || !PURE_SLP_STMT (stmt_info));
   gimple *old_vec_stmt = STMT_VINFO_VEC_STMT (stmt_info);
 
+  bool nested_p = (STMT_VINFO_LOOP_VINFO (stmt_info)
+                  && nested_in_vect_loop_p
+                       (LOOP_VINFO_LOOP (STMT_VINFO_LOOP_VINFO (stmt_info)),
+                        stmt));
+
   switch (STMT_VINFO_TYPE (stmt_info))
     {
     case type_demotion_vec_info_type:
@@ -9525,9 +9530,7 @@ vect_transform_stmt (gimple *stmt, gimple_stmt_iterator *gsi,
   /* Handle inner-loop stmts whose DEF is used in the loop-nest that
      is being vectorized, but outside the immediately enclosing loop.  */
   if (vec_stmt
-      && STMT_VINFO_LOOP_VINFO (stmt_info)
-      && nested_in_vect_loop_p (LOOP_VINFO_LOOP (
-                                STMT_VINFO_LOOP_VINFO (stmt_info)), stmt)
+      && nested_p
       && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type
       && (STMT_VINFO_RELEVANT (stmt_info) == vect_used_in_outer
           || STMT_VINFO_RELEVANT (stmt_info) ==