From: Bill Schmidt Date: Tue, 30 Jul 2013 01:01:35 +0000 (+0000) Subject: re PR tree-optimization/57993 (ICE: verify_ssa failed (definition in block n does... X-Git-Tag: releases/gcc-4.9.0~4787 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0100cd3f7e52acbf862e6c46e5d56c348fffb88c;p=thirdparty%2Fgcc.git re PR tree-optimization/57993 (ICE: verify_ssa failed (definition in block n does not dominate use in block m)) gcc: 2013-07-29 Bill Schmidt PR tree-optimization/57993 * gimple-ssa-strength-reduction.c (replace_mult_candidate): Record replaced statement in the candidate table. (phi_add_costs): Return infinite cost when the hidden basis does not dominate all phis on which the candidate is dependent. (replace_one_candidate): Record replaced statement in the candidate table. gcc/testsuite: 2013-07-29 Bill Schmidt PR tree-optimization/57993 * gcc.dg/torture/pr57993.c: New test. From-SVN: r201325 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2d01701c1bbc..6274a963975f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2013-07-29 Bill Schmidt + + PR tree-optimization/57993 + * gimple-ssa-strength-reduction.c (replace_mult_candidate): Record + replaced statement in the candidate table. + (phi_add_costs): Return infinite cost when the hidden basis does + not dominate all phis on which the candidate is dependent. + (replace_one_candidate): Record replaced statement in the + candidate table. + 2013-07-29 Joern Rennecke * config/epiphany/epiphany.md (*isub_i+2): New peephole. diff --git a/gcc/gimple-ssa-strength-reduction.c b/gcc/gimple-ssa-strength-reduction.c index 9a53bf7c3397..edb1afc0a041 100644 --- a/gcc/gimple-ssa-strength-reduction.c +++ b/gcc/gimple-ssa-strength-reduction.c @@ -1882,6 +1882,7 @@ replace_mult_candidate (slsr_cand_t c, tree basis_name, double_int bump) gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); gsi_replace (&gsi, copy_stmt, false); + c->cand_stmt = copy_stmt; if (dump_file && (dump_flags & TDF_DETAILS)) stmt_to_print = copy_stmt; } @@ -2179,6 +2180,18 @@ phi_add_costs (gimple phi, slsr_cand_t c, int one_add_cost) int cost = 0; slsr_cand_t phi_cand = base_cand_from_table (gimple_phi_result (phi)); + /* If we work our way back to a phi that isn't dominated by the hidden + basis, this isn't a candidate for replacement. Indicate this by + returning an unreasonably high cost. It's not easy to detect + these situations when determining the basis, so we defer the + decision until now. */ + basic_block phi_bb = gimple_bb (phi); + slsr_cand_t basis = lookup_cand (c->basis); + basic_block basis_bb = gimple_bb (basis->cand_stmt); + + if (phi_bb == basis_bb || !dominated_by_p (CDI_DOMINATORS, phi_bb, basis_bb)) + return COST_INFINITE; + for (i = 0; i < gimple_phi_num_args (phi); i++) { tree arg = gimple_phi_arg_def (phi, i); @@ -3226,6 +3239,7 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name) gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); gimple_set_location (copy_stmt, gimple_location (c->cand_stmt)); gsi_replace (&gsi, copy_stmt, false); + c->cand_stmt = copy_stmt; if (dump_file && (dump_flags & TDF_DETAILS)) stmt_to_print = copy_stmt; @@ -3238,6 +3252,7 @@ replace_one_candidate (slsr_cand_t c, unsigned i, tree basis_name) NULL_TREE); gimple_set_location (cast_stmt, gimple_location (c->cand_stmt)); gsi_replace (&gsi, cast_stmt, false); + c->cand_stmt = cast_stmt; if (dump_file && (dump_flags & TDF_DETAILS)) stmt_to_print = cast_stmt; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7f64e515e67f..bbc2ca6b7371 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-07-29 Bill Schmidt + + PR tree-optimization/57993 + * gcc.dg/torture/pr57993.c: New test. + 2013-07-29 Joern Rennecke * gcc.dg/tree-ssa/pr44258.c: Disable scan test for Epiphany. diff --git a/gcc/testsuite/gcc.dg/torture/pr57993.c b/gcc/testsuite/gcc.dg/torture/pr57993.c new file mode 100644 index 000000000000..e73b73f4fa3b --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr57993.c @@ -0,0 +1,30 @@ +/* This ICEd prior to fixing PR57993. */ +/* { dg-do compile } */ + +int a, b, c, d; +char e; +unsigned g; + +void f(void) +{ + int h; + + for(; d; d++) + if(d) +lbl: + g + a || (d = 0); + + b && (a = e); + + for(h = 0; h < 1; ++h) + { + h = c ? : (d = 0); + g = a = (e | 0); + } + + if(a) + goto lbl; + + a = e = 0; + goto lbl; +}