]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/81354 (Segmentation fault in SSA Strength Reduction...
authorBill Schmidt <wschmidt@linux.vnet.ibm.com>
Wed, 16 Aug 2017 14:13:27 +0000 (14:13 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Wed, 16 Aug 2017 14:13:27 +0000 (14:13 +0000)
[gcc]

2017-08-16  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

Backport from mainline
2017-08-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

PR tree-optimization/81354
* gimple-ssa-strength-reduction.c (create_add_on_incoming_edge):
Insert on edges rather than explicitly creating landing pads.
(analyze_candidates_and_replace): Commit edge inserts.

[gcc/testsuite]

2017-08-16  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

Backport from mainline
2017-08-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

PR tree-optimization/81354
* g++.dg/torture/pr81354.C: New file.

From-SVN: r251122

gcc/ChangeLog
gcc/gimple-ssa-strength-reduction.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr81354.C [new file with mode: 0644]

index 3b431ce83f4ff296f794f603886784a5233fb1c4..3932ee83d6902de484239b7f4415685a5d654f75 100644 (file)
@@ -1,3 +1,13 @@
+2017-08-16  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       Backport from mainline
+       2017-08-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR tree-optimization/81354
+       * gimple-ssa-strength-reduction.c (create_add_on_incoming_edge):
+       Insert on edges rather than explicitly creating landing pads.
+       (analyze_candidates_and_replace): Commit edge inserts.
+
 2017-07-31  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/81604
index 77c5a05088453ae0c18e342889085503d0e92455..8f7c56d6085a40511a5a0eb3a2fc5f163ae9cc3c 100644 (file)
@@ -2178,8 +2178,6 @@ create_add_on_incoming_edge (slsr_cand_t c, tree basis_name,
                             widest_int increment, edge e, location_t loc,
                             bool known_stride)
 {
-  basic_block insert_bb;
-  gimple_stmt_iterator gsi;
   tree lhs, basis_type;
   gassign *new_stmt;
 
@@ -2234,19 +2232,13 @@ create_add_on_incoming_edge (slsr_cand_t c, tree basis_name,
        gcc_unreachable ();
     }
 
-  insert_bb = single_succ_p (e->src) ? e->src : split_edge (e);
-  gsi = gsi_last_bb (insert_bb);
-
-  if (!gsi_end_p (gsi) && is_ctrl_stmt (gsi_stmt (gsi)))
-    gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT);
-  else
-    gsi_insert_after (&gsi, new_stmt, GSI_NEW_STMT);
-
   gimple_set_location (new_stmt, loc);
+  gsi_insert_on_edge (e, new_stmt);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
-      fprintf (dump_file, "Inserting in block %d: ", insert_bb->index);
+      fprintf (dump_file, "Inserting on edge %d->%d: ", e->src->index,
+              e->dest->index);
       print_gimple_stmt (dump_file, new_stmt, 0, 0);
     }
 
@@ -3614,6 +3606,10 @@ analyze_candidates_and_replace (void)
          free (incr_vec);
        }
     }
+
+  /* For conditional candidates, we may have uncommitted insertions
+     on edges to clean up.  */
+  gsi_commit_edge_inserts ();
 }
 
 namespace {
index 26841b60fe67b49ef45820f3279acb38597bd224..f57bfb079e8cecba8193cbba7b29a7339b59c745 100644 (file)
@@ -1,3 +1,11 @@
+2017-08-16  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       Backport from mainline
+       2017-08-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
+
+       PR tree-optimization/81354
+       * g++.dg/torture/pr81354.C: New file.
+
 2017-07-31  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/81604
diff --git a/gcc/testsuite/g++.dg/torture/pr81354.C b/gcc/testsuite/g++.dg/torture/pr81354.C
new file mode 100644 (file)
index 0000000..b3ba8f0
--- /dev/null
@@ -0,0 +1,24 @@
+// PR81354 reported this test as crashing in a limited range of revisions.
+// { dg-do compile }
+
+struct T { double a; double b; };
+
+void foo(T Ad[], int As[2])
+{
+  int j;
+  int i;
+  int Bs[2] = {0,0};
+  T Bd[16];
+
+  for (j = 0; j < 4; j++) {
+    for (i = 0; i + 1 <= j + 1; i++) {
+      Ad[i + As[0] * j] = Bd[i + Bs[0] * j];
+    }
+
+    i = j + 1;  // <- comment out this line and it does not crash
+    for (; i + 1 < 5; i++) {
+      Ad[i + As[0] * j].a = 0.0;
+      Ad[i + As[0] * j].b = 0.0;
+    }
+  }
+}