re PR tree-optimization/41778 (missed dead store elimination)

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.

From-SVN: r153491
This commit is contained in:
Richard Guenther 2009-10-23 09:34:46 +00:00 committed by Richard Biener
parent 17e72e5d22
commit 5813994e3c
4 changed files with 53 additions and 5 deletions

View file

@ -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().

View file

@ -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

View file

@ -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" } } */

View file

@ -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 =