summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-pre.c
diff options
context:
space:
mode:
authormkuvyrkov <mkuvyrkov@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-28 01:56:54 +0000
committermkuvyrkov <mkuvyrkov@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-28 01:56:54 +0000
commit0f9b384de2d29d51baa356d56b8b8ee006b33e31 (patch)
treefa87f8c36fc8d168b8c0ab80f20d01bb470d9374 /gcc/tree-ssa-pre.c
parentffe743cadddbe3aecc2f789ffb11f76175521374 (diff)
downloadgcc-0f9b384de2d29d51baa356d56b8b8ee006b33e31.tar.gz
PR tree-optimization/38785
* common.opt (ftree-partial-pre): New option. * doc/invoke.texi: Document it. * opts.c (default_options_table): Initialize flag_tree_partial_pre. * tree-ssa-pre.c (do_partial_partial_insertion): Insert only if it will benefit speed path. (execute_pre): Use flag_tree_partial_pre. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186928 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r--gcc/tree-ssa-pre.c48
1 files changed, 40 insertions, 8 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index e3e55ef48a8..a89856aa959 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3774,20 +3774,51 @@ do_partial_partial_insertion (basic_block block, basic_block dom)
}
else
avail[bprime->index] = edoubleprime;
-
}
/* If we can insert it, it's not the same value
already existing along every predecessor, and
it's defined by some predecessor, it is
partially redundant. */
- if (!cant_insert && by_all && dbg_cnt (treepre_insert))
+ if (!cant_insert && by_all)
{
- pre_stats.pa_insert++;
- if (insert_into_preds_of_block (block, get_expression_id (expr),
- avail))
- new_stuff = true;
- }
+ edge succ;
+ bool do_insertion = false;
+
+ /* Insert only if we can remove a later expression on a path
+ that we want to optimize for speed.
+ The phi node that we will be inserting in BLOCK is not free,
+ and inserting it for the sake of !optimize_for_speed successor
+ may cause regressions on the speed path. */
+ FOR_EACH_EDGE (succ, ei, block->succs)
+ {
+ if (bitmap_set_contains_value (PA_IN (succ->dest), val))
+ {
+ if (optimize_edge_for_speed_p (succ))
+ do_insertion = true;
+ }
+ }
+
+ if (!do_insertion)
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ fprintf (dump_file, "Skipping partial partial redundancy "
+ "for expression ");
+ print_pre_expr (dump_file, expr);
+ fprintf (dump_file, " (%04d), not partially anticipated "
+ "on any to be optimized for speed edges\n", val);
+ }
+ }
+ else if (dbg_cnt (treepre_insert))
+ {
+ pre_stats.pa_insert++;
+ if (insert_into_preds_of_block (block,
+ get_expression_id (expr),
+ avail))
+ new_stuff = true;
+ }
+ }
free (avail);
}
}
@@ -4948,7 +4979,8 @@ execute_pre (bool do_fre)
{
unsigned int todo = 0;
- do_partial_partial = optimize > 2 && optimize_function_for_speed_p (cfun);
+ do_partial_partial =
+ flag_tree_partial_pre && optimize_function_for_speed_p (cfun);
/* This has to happen before SCCVN runs because
loop_optimizer_init may create new phis, etc. */