Commit e9bd9cf3 by Daniel Berlin Committed by Daniel Berlin

re PR middle-end/23488 (GCSE load PRE does not work with non sets (or missing…

re PR middle-end/23488 (GCSE load PRE does not work with non sets (or missing load PRE with plain decls))

2007-07-06  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/23488

	* tree-ssa-sccvn.c (expr_has_constants): Handle tcc_declaration.
	(try_to_simplify): Ditto.
	(visit_use): Ditto.
	* tree-vn.c (set_value_handle): Use decl_vh_map for decl value
	handles.
	* tree-flow-inline.h (get_value_handle): Ditto.
	* tree-ssa-pre.c (decl_vh_map): New.
	(decl_node_pool): New.
	(can_value_number_operation): Support DECL_P.
	(can_PRE_operation): Ditto.
	(create_expression_by_pieces): Ditto.
	(find_existing_value_expr): Modify to differnetiate between
	addressing and top level.
	(create_value_handle_for_expr): Handle DECL's.
	(poolify_tree): Ditto.
	(make_values_for_phi): Don't insert into PHI_GEN during FRE.
	(make_values_for_stmt): Handle DECL's properly.
	(init_pre): Reorg to not init useless things during FRE.
	(fini_pre): Ditto.
	* tree-flow.h: Include pointer-set.h.
	(decl_vh_map): Declare.
	* Makefile.in (TREE_FLOW_H): Add pointer-set.h

From-SVN: r126434
parent 3673b8ca
2007-07-06 Daniel Berlin <dberlin@dberlin.org>
Fix PR tree-optimization/23488
* tree-ssa-sccvn.c (expr_has_constants): Handle tcc_declaration.
(try_to_simplify): Ditto.
(visit_use): Ditto.
* tree-vn.c (set_value_handle): Use decl_vh_map for decl value
handles.
* tree-flow-inline.h (get_value_handle): Ditto.
* tree-ssa-pre.c (decl_vh_map): New.
(decl_node_pool): New.
(can_value_number_operation): Support DECL_P.
(can_PRE_operation): Ditto.
(create_expression_by_pieces): Ditto.
(find_existing_value_expr): Modify to differnetiate between
addressing and top level.
(create_value_handle_for_expr): Handle DECL's.
(poolify_tree): Ditto.
(make_values_for_phi): Don't insert into PHI_GEN during FRE.
(make_values_for_stmt): Handle DECL's properly.
(init_pre): Reorg to not init useless things during FRE.
(fini_pre): Ditto.
* tree-flow.h: Include pointer-set.h.
(decl_vh_map): Declare.
* Makefile.in (TREE_FLOW_H): Add pointer-set.h
2007-07-06 Sandra Loosemore <sandra@codesourcery.com> 2007-07-06 Sandra Loosemore <sandra@codesourcery.com>
* c-opts.c (c_common_handle_option): Make DOLLARS_IN_IDENTIFIERS * c-opts.c (c_common_handle_option): Make DOLLARS_IN_IDENTIFIERS
......
...@@ -805,7 +805,7 @@ TREE_DUMP_H = tree-dump.h $(SPLAY_TREE_H) ...@@ -805,7 +805,7 @@ TREE_DUMP_H = tree-dump.h $(SPLAY_TREE_H)
TREE_GIMPLE_H = tree-gimple.h tree-iterator.h TREE_GIMPLE_H = tree-gimple.h tree-iterator.h
TREE_FLOW_H = tree-flow.h tree-flow-inline.h tree-ssa-operands.h \ TREE_FLOW_H = tree-flow.h tree-flow-inline.h tree-ssa-operands.h \
bitmap.h $(BASIC_BLOCK_H) hard-reg-set.h $(TREE_GIMPLE_H) \ bitmap.h $(BASIC_BLOCK_H) hard-reg-set.h $(TREE_GIMPLE_H) \
$(HASHTAB_H) $(CGRAPH_H) $(IPA_REFERENCE_H) $(HASHTAB_H) $(CGRAPH_H) $(IPA_REFERENCE_H) pointer-set.h
TREE_SSA_LIVE_H = tree-ssa-live.h $(PARTITION_H) vecprim.h TREE_SSA_LIVE_H = tree-ssa-live.h $(PARTITION_H) vecprim.h
PRETTY_PRINT_H = pretty-print.h input.h $(OBSTACK_H) PRETTY_PRINT_H = pretty-print.h input.h $(OBSTACK_H)
DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H) options.h DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H) options.h
......
2007-07-06 Daniel Berlin <dberlin@dberlin.org>
* gcc.dg/tree-ssa/ssa-pre-17.c: New test.
* gcc.dg/tree-ssa/ssa-fre-7.c: New test.
2007-07-06 Nathan Froyd <froydnj@codesourcery.com> 2007-07-06 Nathan Froyd <froydnj@codesourcery.com>
* gcc.dg/20001012-1.c: Run on all fpic-capable targets. * gcc.dg/20001012-1.c: Run on all fpic-capable targets.
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-fre-details" } */
int i; int foo(void) { i = 2; int j = i * 2; int k = i + 2; return j == k; }
/* { dg-final { scan-tree-dump-times "Replaced " 5 "fre" } } */
/* { dg-final { cleanup-tree-dump "fre" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-details" } */
int i;
int foo(int q) {
int j;
int p;
for (j = 0; j < 9; j++)
{
p = i + q;
}
return p;
}
/* We should replace p = a load from i that will pop into the loop, with a hoisted version.
We should also replace i + q with a hoisted version. */
/* { dg-final { scan-tree-dump-times "Replaced " 2 "pre" } } */
/* { dg-final { cleanup-tree-dump "pre" } } */
...@@ -1792,12 +1792,20 @@ get_value_handle (tree expr) ...@@ -1792,12 +1792,20 @@ get_value_handle (tree expr)
{ {
if (TREE_CODE (expr) == SSA_NAME) if (TREE_CODE (expr) == SSA_NAME)
return SSA_NAME_VALUE (expr); return SSA_NAME_VALUE (expr);
else if (DECL_P (expr) || TREE_CODE (expr) == TREE_LIST else if (TREE_CODE (expr) == TREE_LIST
|| TREE_CODE (expr) == CONSTRUCTOR) || TREE_CODE (expr) == CONSTRUCTOR)
{ {
tree_ann_common_t ann = tree_common_ann (expr); tree_ann_common_t ann = tree_common_ann (expr);
return ((ann) ? ann->value_handle : NULL_TREE); return ((ann) ? ann->value_handle : NULL_TREE);
} }
else if (DECL_P (expr))
{
tree *result = (tree *)pointer_map_contains (decl_vh_map,
expr);
if (result)
return *result;
return NULL_TREE;
}
else if (is_gimple_min_invariant (expr)) else if (is_gimple_min_invariant (expr))
return expr; return expr;
else if (EXPR_P (expr)) else if (EXPR_P (expr))
......
...@@ -31,6 +31,7 @@ Boston, MA 02110-1301, USA. */ ...@@ -31,6 +31,7 @@ Boston, MA 02110-1301, USA. */
#include "tree-ssa-operands.h" #include "tree-ssa-operands.h"
#include "cgraph.h" #include "cgraph.h"
#include "ipa-reference.h" #include "ipa-reference.h"
#include "pointer-set.h"
/* Forward declare structures for the garbage collector GTY markers. */ /* Forward declare structures for the garbage collector GTY markers. */
#ifndef GCC_BASIC_BLOCK_H #ifndef GCC_BASIC_BLOCK_H
...@@ -1081,7 +1082,7 @@ extern bool maybe_clean_or_replace_eh_stmt (tree, tree); ...@@ -1081,7 +1082,7 @@ extern bool maybe_clean_or_replace_eh_stmt (tree, tree);
void add_to_value (tree, tree); void add_to_value (tree, tree);
void debug_value_expressions (tree); void debug_value_expressions (tree);
void print_value_expressions (FILE *, tree); void print_value_expressions (FILE *, tree);
extern struct pointer_map_t *decl_vh_map;
/* In tree-vn.c */ /* In tree-vn.c */
tree make_value_handle (tree); tree make_value_handle (tree);
......
...@@ -1332,6 +1332,7 @@ expr_has_constants (tree expr) ...@@ -1332,6 +1332,7 @@ expr_has_constants (tree expr)
/* Constants inside reference ops are rarely interesting, but /* Constants inside reference ops are rarely interesting, but
it can take a lot of looking to find them. */ it can take a lot of looking to find them. */
case tcc_reference: case tcc_reference:
case tcc_declaration:
return false; return false;
default: default:
return is_gimple_min_invariant (expr); return is_gimple_min_invariant (expr);
...@@ -1453,7 +1454,7 @@ try_to_simplify (tree stmt, tree rhs) ...@@ -1453,7 +1454,7 @@ try_to_simplify (tree stmt, tree rhs)
{ {
/* For references, see if we find a result for the lookup, /* For references, see if we find a result for the lookup,
and use it if we do. */ and use it if we do. */
case tcc_declaration:
case tcc_reference: case tcc_reference:
{ {
tree result = vn_reference_lookup (rhs, tree result = vn_reference_lookup (rhs,
...@@ -1613,7 +1614,7 @@ visit_use (tree use) ...@@ -1613,7 +1614,7 @@ visit_use (tree use)
if (TREE_CODE (lhs) == SSA_NAME if (TREE_CODE (lhs) == SSA_NAME
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs)) && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
changed = defs_to_varying (stmt); changed = defs_to_varying (stmt);
else if (REFERENCE_CLASS_P (lhs)) else if (REFERENCE_CLASS_P (lhs) || DECL_P (lhs))
{ {
changed = visit_reference_op_store (lhs, rhs, stmt); changed = visit_reference_op_store (lhs, rhs, stmt);
} }
......
...@@ -83,6 +83,10 @@ expressions_equal_p (tree e1, tree e2) ...@@ -83,6 +83,10 @@ expressions_equal_p (tree e1, tree e2)
return true; return true;
} }
else if (TREE_CODE (e1) == TREE_CODE (e2)
&& DECL_P (e1)
&& te1 == te2)
return DECL_UID (e1) == DECL_UID (e2);
else if (TREE_CODE (e1) == TREE_CODE (e2) else if (TREE_CODE (e1) == TREE_CODE (e2)
&& (te1 == te2 && (te1 == te2
|| types_compatible_p (te1, te2)) || types_compatible_p (te1, te2))
...@@ -99,7 +103,12 @@ set_value_handle (tree e, tree v) ...@@ -99,7 +103,12 @@ set_value_handle (tree e, tree v)
{ {
if (TREE_CODE (e) == SSA_NAME) if (TREE_CODE (e) == SSA_NAME)
SSA_NAME_VALUE (e) = v; SSA_NAME_VALUE (e) = v;
else if (EXPR_P (e) || DECL_P (e) || TREE_CODE (e) == TREE_LIST else if (DECL_P (e))
{
tree *slot = (tree *)pointer_map_insert (decl_vh_map, e);
*slot = v;
}
else if (EXPR_P (e) || TREE_CODE (e) == TREE_LIST
|| GIMPLE_STMT_P (e) || GIMPLE_STMT_P (e)
|| TREE_CODE (e) == CONSTRUCTOR) || TREE_CODE (e) == CONSTRUCTOR)
get_tree_common_ann (e)->value_handle = v; get_tree_common_ann (e)->value_handle = v;
......
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