Commit 43da81be by Daniel Berlin Committed by Daniel Berlin

re PR tree-optimization/21576 (FRE does not eliminate a redundant builtin call.)

2005-05-15  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/21576

	* tree-ssa-pre.c (expression_node_pool): New pool.
	(comparison_node_pool): Ditto.
	(list_node_pool): Ditto.
	(pool_copy_list): New function.
	(phi_translate): Handle CALL_EXPR.
	(valid_in_set): Ditto.
	(create_expression_by_pieces): Ditto.
	(insert_into_preds_of_block): Ditto.
	(insert_aux): Ditto.
	(compute_avail): Ditto.
	(create_value_expr_from): Handle TREE_LIST and CALL_EXPR.
	(can_value_number_call): New function.
	(find_leader): Update comment.
	(init_pre): Create new pools.
	(fini_pre): Free new pools.
	(pass_pre): Add TODO_update_ssa for the future when we are going
	to need vops.
	* tree-vn.c (expressions_equal_p): Handle TREE_LIST.
	(set_value_handle): Ditto.
	(get_value_handle): Ditto.

From-SVN: r99759
parent cea02b6e
2005-05-15 Daniel Berlin <dberlin@dberlin.org>
Fix PR tree-optimization/21576
* tree-ssa-pre.c (expression_node_pool): New pool.
(comparison_node_pool): Ditto.
(list_node_pool): Ditto.
(pool_copy_list): New function.
(phi_translate): Handle CALL_EXPR.
(valid_in_set): Ditto.
(create_expression_by_pieces): Ditto.
(insert_into_preds_of_block): Ditto.
(insert_aux): Ditto.
(compute_avail): Ditto.
(create_value_expr_from): Handle TREE_LIST and CALL_EXPR.
(can_value_number_call): New function.
(find_leader): Update comment.
(init_pre): Create new pools.
(fini_pre): Free new pools.
(pass_pre): Add TODO_update_ssa for the future when we are going
to need vops.
* tree-vn.c (expressions_equal_p): Handle TREE_LIST.
(set_value_handle): Ditto.
(get_value_handle): Ditto.
2005-05-15 Richard Earnshaw <richard.earnshaw@arm.com>
* arm.c (thumb_unexpanded_epilogue): Delete unused variable 'mode'.
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dom1-details" } */
/* { dg-options "-O2 -fdump-tree-fre-details" } */
int t(int a) __attribute__ ((const));
void q (void);
void
......@@ -12,5 +12,5 @@ threading(int a,int b)
}
}
/* We should thread the jump twice and eliminate it. */
/* { dg-final { scan-tree-dump-times "Replaced.* t " 1 "dom1"} } */
/* { dg-final { cleanup-tree-dump "dom1" } } */
/* { dg-final { scan-tree-dump-times "Replaced.* t " 1 "fre"} } */
/* { dg-final { cleanup-tree-dump "fre" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-fre-stats" } */
double cos (double);
void link_error();
void f(double a)
{
double b = cos (a);
double c = cos (a);
if (b != c)
link_error();
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "fre"} } */
/* { dg-final { cleanup-tree-dump "fre" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
double cos (double);
double f(double a)
{
double b;
double c,d;
if (a < 2.0)
{
c = cos (a);
}
else
{
c = 1.0;
}
d = cos (a);
return d + c;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre"} } */
/* { dg-final { cleanup-tree-dump "pre" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
double cos (double) __attribute__ ((const));
double sin (double) __attribute__ ((const));
double f(double a)
{
double b;
double c,d;
double (*fp) (double) __attribute__ ((const));
/* Fully redundant call, but we need a phi node to merge the results. */
if (a < 2.0)
{
fp = sin;
c = fp (a);
}
else
{
c = 1.0;
fp = cos;
c = fp (a);
}
d = fp (a);
return d + c;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre"} } */
/* { dg-final { cleanup-tree-dump "pre" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-stats" } */
double cos (double) __attribute__ ((const));
double sin (double) __attribute__ ((const));
double f(double a)
{
double b;
double c,d;
double (*fp) (double) __attribute__ ((const));
/* Partially redundant call */
if (a < 2.0)
{
fp = sin;
c = fp (a);
}
else
{
c = 1.0;
fp = cos;
}
d = fp (a);
return d + c;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre"} } */
/* { dg-final { cleanup-tree-dump "pre" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-fre-stats" } */
int
foo (unsigned long a)
{
int b = __builtin_clzl (a);
int c = __builtin_clzl (a);
if (b == c)
return 1;
return 0;
}
/* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "fre"} } */
/* { dg-final { cleanup-tree-dump "fre" } } */
......@@ -119,9 +119,25 @@ expressions_equal_p (tree e1, tree e2)
te1 = TREE_TYPE (e1);
te2 = TREE_TYPE (e2);
if (TREE_CODE (e1) == TREE_CODE (e2)
&& (te1 == te2 || lang_hooks.types_compatible_p (te1, te2))
&& operand_equal_p (e1, e2, OEP_PURE_SAME))
if (TREE_CODE (e1) == TREE_LIST && TREE_CODE (e2) == TREE_LIST)
{
tree lop1 = e1;
tree lop2 = e2;
for (lop1 = e1, lop2 = e2;
lop1 || lop2;
lop1 = TREE_CHAIN (lop1), lop2 = TREE_CHAIN (lop2))
{
if (!lop1 || !lop2)
return false;
if (!expressions_equal_p (TREE_VALUE (lop1), TREE_VALUE (lop2)))
return false;
}
return true;
}
else if (TREE_CODE (e1) == TREE_CODE (e2)
&& (te1 == te2 || lang_hooks.types_compatible_p (te1, te2))
&& operand_equal_p (e1, e2, OEP_PURE_SAME))
return true;
return false;
......@@ -166,7 +182,7 @@ set_value_handle (tree e, tree v)
{
if (TREE_CODE (e) == SSA_NAME)
SSA_NAME_VALUE (e) = v;
else if (EXPR_P (e) || DECL_P (e))
else if (EXPR_P (e) || DECL_P (e) || TREE_CODE (e) == TREE_LIST)
get_tree_ann (e)->common.value_handle = v;
else
/* Do nothing. Constants are their own value handles. */
......@@ -271,7 +287,7 @@ get_value_handle (tree expr)
if (TREE_CODE (expr) == SSA_NAME)
return SSA_NAME_VALUE (expr);
else if (EXPR_P (expr) || DECL_P (expr))
else if (EXPR_P (expr) || DECL_P (expr) || TREE_CODE (expr) == TREE_LIST)
{
tree_ann_t ann = tree_ann (expr);
return ((ann) ? ann->common.value_handle : NULL_TREE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment