diff options
author | Jeff Law <law@redhat.com> | 2016-01-27 12:19:47 -0700 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2016-01-27 12:19:47 -0700 |
commit | 2b572b3c213b51854f5344654f23e11eaa83563e (patch) | |
tree | d12efa856784b2c9751e6eb3e813f70f08470400 /gcc/tree-ssa-threadbackward.c | |
parent | fa74a4bca84aabe0a1500e4fe5359895c1f07e55 (diff) | |
download | gcc-2b572b3c213b51854f5344654f23e11eaa83563e.zip gcc-2b572b3c213b51854f5344654f23e11eaa83563e.tar.gz gcc-2b572b3c213b51854f5344654f23e11eaa83563e.tar.bz2 |
re PR tree-optimization/68398 (coremark regression due to r229685)
PR tree-optimization/68398
* params.def (PARAM_FSM_SCALE_PATH_STMTS): New parameter.
(PARAM_FSM_SCALE_PATH_BLOCKS): Likewise.
* tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths):
Only count PHIs in the last block in the path. The others will
const/copy propagate away. Add heuristic to allow more irreducible
subloops to be created when it is likely profitable to do so.
* tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths):
Fix typo in comment. Use gsi_after_labels and remove the GIMPLE_LABEL
check from within the loop. Use gsi_next_nondebug rather than gsi_next.
PR tree-optimization/68398
* gcc.dg/tree-ssa/pr66752-3.c: Update expected output.
* gcc.dg/tree-ssa/ssa-dom-thread-2c.c: Add extra statements on thread
path to avoid new heuristic allowing more irreducible regions
* gcc.dg/tree-ssa/ssa-dom-thread-2d.c: Likewise.
* gcc.dg/tree-ssa/vrp46.c: Likewise.
* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Update expected output.
* gcc.dg/tree-ssa/ssa-dom-thread-2g.c: New test.
* gcc.dg/tree-ssa/ssa-dom-thread-2h.c: Likewise.
From-SVN: r232897
Diffstat (limited to 'gcc/tree-ssa-threadbackward.c')
-rw-r--r-- | gcc/tree-ssa-threadbackward.c | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 131630e..735009c 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -266,7 +266,7 @@ fsm_find_control_statement_thread_paths (tree name, basic_block bb = (*path)[j]; /* Remember, blocks in the path are stored in opposite order - in the PATH array. The last entry in the array reprensents + in the PATH array. The last entry in the array represents the block with an outgoing edge that we will redirect to the jump threading path. Thus we don't care about that block's loop father, nor how many statements are in that block because @@ -280,33 +280,19 @@ fsm_find_control_statement_thread_paths (tree name, break; } - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + for (gsi = gsi_after_labels (bb); + !gsi_end_p (gsi); + gsi_next_nondebug (&gsi)) { gimple *stmt = gsi_stmt (gsi); /* Do not count empty statements and labels. */ if (gimple_code (stmt) != GIMPLE_NOP - && gimple_code (stmt) != GIMPLE_LABEL && !(gimple_code (stmt) == GIMPLE_ASSIGN && gimple_assign_rhs_code (stmt) == ASSERT_EXPR) && !is_gimple_debug (stmt)) ++n_insns; } - gphi_iterator gsip; - for (gsip = gsi_start_phis (bb); - !gsi_end_p (gsip); - gsi_next (&gsip)) - { - gphi *phi = gsip.phi (); - tree dst = gimple_phi_result (phi); - - /* We consider any non-virtual PHI as a statement since it - count result in a constant assignment or copy - operation. */ - if (!virtual_operand_p (dst)) - ++n_insns; - } - /* We do not look at the block with the threaded branch in this loop. So if any block with a last statement that is a GIMPLE_SWITCH or GIMPLE_GOTO is seen, then we have a @@ -360,6 +346,24 @@ fsm_find_control_statement_thread_paths (tree name, == DOMST_NONDOMINATING)) creates_irreducible_loop = true; + /* PHIs in the final target and only the final target will need + to be duplicated. So only count those against the number + of statements. */ + gphi_iterator gsip; + for (gsip = gsi_start_phis (taken_edge->dest); + !gsi_end_p (gsip); + gsi_next (&gsip)) + { + gphi *phi = gsip.phi (); + tree dst = gimple_phi_result (phi); + + /* We consider any non-virtual PHI as a statement since it + count result in a constant assignment or copy + operation. */ + if (!virtual_operand_p (dst)) + ++n_insns; + } + if (path_crosses_loops) { if (dump_file && (dump_flags & TDF_DETAILS)) @@ -379,10 +383,18 @@ fsm_find_control_statement_thread_paths (tree name, continue; } - /* We avoid creating irreducible loops unless we thread through + /* We avoid creating irreducible inner loops unless we thread through a multiway branch, in which case we have deemed it worth losing other - loop optimizations later. */ - if (!threaded_multiway_branch && creates_irreducible_loop) + loop optimizations later. + + We also consider it worth creating an irreducible inner loop if + the number of copied statement is low relative to the length of + the path -- in that case there's little the traditional loop optimizer + would have done anyway, so an irreducible loop is not so bad. */ + if (!threaded_multiway_branch && creates_irreducible_loop + && (n_insns * PARAM_VALUE (PARAM_FSM_SCALE_PATH_STMTS) + > path_length * PARAM_VALUE (PARAM_FSM_SCALE_PATH_BLOCKS))) + { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, |