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;
}
}
- 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);
}
- 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);
}
free (incr_vec);
}
}
+
+ /* For conditional candidates, we may have uncommitted insertions
+ on edges to clean up. */
+ gsi_commit_edge_inserts ();
}
namespace {
--- /dev/null
+// 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;
+ }
+ }
+}