summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwschmidt <wschmidt@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-16 14:09:15 +0000
committerwschmidt <wschmidt@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-16 14:09:15 +0000
commit1a940af4db91205ae693ebd0c785ea61f7627ca9 (patch)
tree641b1769db0efec32df383b345d558f8599c7c8c
parentf7f39668bcb21dd333e8adb5304f77ae2f5cc7d1 (diff)
downloadgcc-1a940af4db91205ae693ebd0c785ea61f7627ca9.tar.gz
[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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@251120 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/gimple-ssa-strength-reduction.c36
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/torture/pr81354.C24
4 files changed, 54 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dd78afb68a7..f3a23107eb0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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-08-15 Joseph Myers <joseph@codesourcery.com>
PR target/78460
diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c
index eed1dba5f86..233ece48738 100644
--- a/gcc/gimple-ssa-strength-reduction.c
+++ b/gcc/gimple-ssa-strength-reduction.c
@@ -2193,8 +2193,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, *cast_stmt = NULL;
@@ -2263,39 +2261,25 @@ create_add_on_incoming_edge (slsr_cand_t c, tree basis_name,
}
}
- insert_bb = single_succ_p (e->src) ? e->src : split_edge (e);
- gsi = gsi_last_bb (insert_bb);
-
- if (!gsi_end_p (gsi) && stmt_ends_bb_p (gsi_stmt (gsi)))
+ if (cast_stmt)
{
- gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT);
- if (cast_stmt)
- {
- gsi_insert_before (&gsi, cast_stmt, GSI_SAME_STMT);
- gimple_set_location (cast_stmt, loc);
- }
- }
- else
- {
- if (cast_stmt)
- {
- gsi_insert_after (&gsi, cast_stmt, GSI_NEW_STMT);
- gimple_set_location (cast_stmt, loc);
- }
- gsi_insert_after (&gsi, new_stmt, GSI_NEW_STMT);
+ gimple_set_location (cast_stmt, loc);
+ gsi_insert_on_edge (e, cast_stmt);
}
gimple_set_location (new_stmt, loc);
+ gsi_insert_on_edge (e, new_stmt);
if (dump_file && (dump_flags & TDF_DETAILS))
{
if (cast_stmt)
{
- fprintf (dump_file, "Inserting cast in block %d: ",
- insert_bb->index);
+ fprintf (dump_file, "Inserting cast on edge %d->%d: ",
+ e->src->index, e->dest->index);
print_gimple_stmt (dump_file, cast_stmt, 0, 0);
}
- fprintf (dump_file, "Inserting in block %d: ", insert_bb->index);
+ fprintf (dump_file, "Inserting in block %d: ", e->src->index,
+ e->dest->index);
print_gimple_stmt (dump_file, new_stmt, 0, 0);
}
@@ -3736,6 +3720,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 {
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1db4341c2fd..ba84b703ee4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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-08-15 Joseph Myers <joseph@codesourcery.com>
PR target/78460
diff --git a/gcc/testsuite/g++.dg/torture/pr81354.C b/gcc/testsuite/g++.dg/torture/pr81354.C
new file mode 100644
index 00000000000..b3ba8f09371
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr81354.C
@@ -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;
+ }
+ }
+}