aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-10-23 09:34:46 +0000
committerRichard Guenther <rguenther@suse.de>2009-10-23 09:34:46 +0000
commitaab155d17e7a8033407c0af44ba3589b7b480429 (patch)
treeeb96d46ea128145da9820a137b39b70dcb5a20d4
parent7f81093cdf221fd0503754fa07a24edb749d3b33 (diff)
2009-10-23 Richard Guenther <rguenther@suse.de>
PR tree-optimization/41778 * tree-ssa-pre.c (do_regular_insertion): Only insert if a redundancy along a path in the CFG we want to optimize for speed is going to be removed. (execute_pre): Do partial-PRE only if the function is to be optimized for speed. (gate_pre): Do not turn off all of PRE when not optimizing a function for speed. * gcc.dg/tree-ssa/ssa-pre-26.c: New testcase. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@153491 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-26.c27
-rw-r--r--gcc/tree-ssa-pre.c15
4 files changed, 53 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e03bd07eb34..e0f70c48843 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2009-10-23 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/41778
+ * tree-ssa-pre.c (do_regular_insertion): Only insert if a
+ redundancy along a path in the CFG we want to optimize for speed
+ is going to be removed.
+ (execute_pre): Do partial-PRE only if the function is to be
+ optimized for speed.
+ (gate_pre): Do not turn off all of PRE when not optimizing a
+ function for speed.
+
2009-10-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c (fold_builtin_cabs): Use validate_arg().
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ba31a604cea..aa2522805c2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-10-23 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/41778
+ * gcc.dg/tree-ssa/ssa-pre-26.c: New testcase.
+
2009-10-22 Richard Guenther <rguenther@suse.de>
PR lto/41791
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-26.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-26.c
new file mode 100644
index 00000000000..978b7abab3a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-26.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -fdump-tree-pre-details" } */
+
+typedef union
+{
+ int* data;
+} SA;
+
+typedef struct
+{
+ int reserved;
+ char* array;
+}SB;
+
+typedef struct
+{
+ int status;
+}SC;
+
+void foo(SA* pResult, SB* method, SC* self)
+{
+ if (method->array[0] == 'L' && !self->status && pResult->data != 0)
+ pResult->data = pResult->data;
+}
+
+/* { dg-final { scan-tree-dump "Deleted redundant store" "pre" } } */
+/* { dg-final { cleanup-tree-dump "pre" } } */
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 5da6c63b400..6ae05b5a866 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3405,6 +3405,7 @@ do_regular_insertion (basic_block block, basic_block dom)
pre_expr eprime = NULL;
edge_iterator ei;
pre_expr edoubleprime = NULL;
+ bool do_insertion = false;
val = get_expr_value_id (expr);
if (bitmap_set_contains_value (PHI_GEN (block), val))
@@ -3456,6 +3457,10 @@ do_regular_insertion (basic_block block, basic_block dom)
{
avail[bprime->index] = edoubleprime;
by_some = true;
+ /* We want to perform insertions to remove a redundancy on
+ a path in the CFG we want to optimize for speed. */
+ if (optimize_edge_for_speed_p (pred))
+ do_insertion = true;
if (first_s == NULL)
first_s = edoubleprime;
else if (!pre_expr_eq (first_s, edoubleprime))
@@ -3466,7 +3471,8 @@ do_regular_insertion (basic_block block, basic_block dom)
already existing along every predecessor, and
it's defined by some predecessor, it is
partially redundant. */
- if (!cant_insert && !all_same && by_some && dbg_cnt (treepre_insert))
+ if (!cant_insert && !all_same && by_some && do_insertion
+ && dbg_cnt (treepre_insert))
{
if (insert_into_preds_of_block (block, get_expression_id (expr),
avail))
@@ -4526,11 +4532,11 @@ fini_pre (bool do_fre)
only wants to do full redundancy elimination. */
static unsigned int
-execute_pre (bool do_fre ATTRIBUTE_UNUSED)
+execute_pre (bool do_fre)
{
unsigned int todo = 0;
- do_partial_partial = optimize > 2;
+ do_partial_partial = optimize > 2 && optimize_function_for_speed_p (cfun);
/* This has to happen before SCCVN runs because
loop_optimizer_init may create new phis, etc. */
@@ -4615,8 +4621,7 @@ do_pre (void)
static bool
gate_pre (void)
{
- /* PRE tends to generate bigger code. */
- return flag_tree_pre != 0 && optimize_function_for_speed_p (cfun);
+ return flag_tree_pre != 0;
}
struct gimple_opt_pass pass_pre =