From: Richard Biener Date: Thu, 19 Nov 2020 09:43:35 +0000 (+0100) Subject: tree-optimization/97901 - ICE propagating out LC PHIs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ec383f0bdb4077b744d493d02afff5f13f33029e;p=gcc.git tree-optimization/97901 - ICE propagating out LC PHIs We need to fold the stmt to canonicalize MEM_REFs which means we're back to using replace_uses_by. Which means we need dominators to not require a CFG cleanup upthread. 2020-11-19 Richard Biener PR tree-optimization/97901 * tree-ssa-propagate.c (clean_up_loop_closed_phi): Compute dominators and use replace_uses_by. * gcc.dg/torture/pr97901.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/torture/pr97901.c b/gcc/testsuite/gcc.dg/torture/pr97901.c new file mode 100644 index 00000000000..a6a89ef1e27 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr97901.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ + +int a[1], b, *c, *d; + +int main() { +L: + d = c; + for (b = 0; b < 2; b++) + d = &a[0]; + if (c) + goto L; + if (*d) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 354057b48bf..bc656ff76b1 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1569,6 +1569,10 @@ clean_up_loop_closed_phi (function *fun) if (!loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS)) return 0; + /* replace_uses_by might purge dead EH edges and we want it to also + remove dominated blocks. */ + calculate_dominance_info (CDI_DOMINATORS); + /* Walk over loop in function. */ FOR_EACH_LOOP_FN (fun, loop, 0) { @@ -1595,23 +1599,7 @@ clean_up_loop_closed_phi (function *fun) fprintf (dump_file, "'\n"); } - use_operand_p use_p; - imm_use_iterator iter; - gimple *use_stmt; - FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs) - { - FOR_EACH_IMM_USE_ON_STMT (use_p, iter) - replace_exp (use_p, rhs); - update_stmt (use_stmt); - - /* Update the invariant flag for ADDR_EXPR if replacing - a variable index with a constant. */ - if (gimple_assign_single_p (use_stmt) - && TREE_CODE (gimple_assign_rhs1 (use_stmt)) - == ADDR_EXPR) - recompute_tree_invariant_for_addr_expr ( - gimple_assign_rhs1 (use_stmt)); - } + replace_uses_by (lhs, rhs); remove_phi_node (&gsi, true); } else