diff options
author | Richard Biener <rguenther@suse.de> | 2020-11-19 10:43:35 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-11-19 11:35:45 +0100 |
commit | ec383f0bdb4077b744d493d02afff5f13f33029e (patch) | |
tree | bbf63ed251ec0c1f16ab8fd62e35c51a7c4ffffb /gcc | |
parent | 43a0debd527b75eb564cad6bd47f5d5bb301dfad (diff) | |
download | gcc-ec383f0bdb4077b744d493d02afff5f13f33029e.zip gcc-ec383f0bdb4077b744d493d02afff5f13f33029e.tar.gz gcc-ec383f0bdb4077b744d493d02afff5f13f33029e.tar.bz2 |
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 <rguenther@suse.de>
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr97901.c | 15 | ||||
-rw-r--r-- | gcc/tree-ssa-propagate.c | 22 |
2 files changed, 20 insertions, 17 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr97901.c b/gcc/testsuite/gcc.dg/torture/pr97901.c new file mode 100644 index 0000000..a6a89ef --- /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 354057b..bc656ff 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 |