From 7ec492570b77735583dceb28b091b4fa71ea1320 Mon Sep 17 00:00:00 2001
From: Martin Jambor <mjambor@suse.cz>
Date: Wed, 20 May 2009 12:18:10 +0200
Subject: [PATCH] tree-flow.h (insert_edge_copies_seq): Undeclare.

2009-05-20  Martin Jambor  <mjambor@suse.cz>

	* tree-flow.h (insert_edge_copies_seq): Undeclare.
	(sra_insert_before): Likewise.
	(sra_insert_after): Likewise.
	(sra_init_cache): Likewise.
	(sra_type_can_be_decomposed_p): Likewise.
	* tree-mudflap.c (insert_edge_copies_seq): Copied here from tree-sra.c
	* tree-sra.c (sra_type_can_be_decomposed_p): Made static.
	(sra_insert_before): Likewise.
	(sra_insert_after): Likewise.
	(sra_init_cache): Likewise.
	(insert_edge_copies_seq): Made static and moved upwards.

	* tree-complex.c (extract_component): Added VIEW_CONVERT_EXPR switch
	case.

	* tree-flow-inline.h (contains_view_convert_expr_p): New function.

	* ipa-prop.c (get_ssa_def_if_simple_copy): New function.
	(determine_cst_member_ptr): Call get_ssa_def_if_simple_copy to skip
	simple copies.

From-SVN: r147733
---
 gcc/ChangeLog          | 23 ++++++++++++++++++++
 gcc/ipa-prop.c         | 18 ++++++++++++++++
 gcc/tree-complex.c     |  1 +
 gcc/tree-flow-inline.h | 15 +++++++++++++
 gcc/tree-flow.h        |  7 ------
 gcc/tree-mudflap.c     | 20 ++++++++++++++++++
 gcc/tree-sra.c         | 48 +++++++++++++++++++++---------------------
 7 files changed, 101 insertions(+), 31 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 19a59b5704b8..0e39144b79cb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,26 @@
+2009-05-20  Martin Jambor  <mjambor@suse.cz>
+
+	* tree-flow.h (insert_edge_copies_seq): Undeclare.
+	(sra_insert_before): Likewise.
+	(sra_insert_after): Likewise.
+	(sra_init_cache): Likewise.
+	(sra_type_can_be_decomposed_p): Likewise.
+	* tree-mudflap.c (insert_edge_copies_seq): Copied here from tree-sra.c
+	* tree-sra.c (sra_type_can_be_decomposed_p): Made static.
+	(sra_insert_before): Likewise.
+	(sra_insert_after): Likewise.
+	(sra_init_cache): Likewise.
+	(insert_edge_copies_seq): Made static and moved upwards.
+
+	* tree-complex.c (extract_component): Added VIEW_CONVERT_EXPR switch
+	case.
+
+	* tree-flow-inline.h (contains_view_convert_expr_p): New function.
+
+	* ipa-prop.c (get_ssa_def_if_simple_copy): New function.
+	(determine_cst_member_ptr): Call get_ssa_def_if_simple_copy to skip
+	simple copies.
+
 2009-05-20  Richard Guenther  <rguenther@suse.de>
 
 	* expr.c (expand_expr_real_1): Avoid calling do_store_flag
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 90889137208c..6f5e26b2042d 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -428,6 +428,22 @@ fill_member_ptr_cst_jump_function (struct ipa_jump_func *jfunc,
   jfunc->value.member_cst.delta = delta;
 }
 
+/* If RHS is an SSA_NAMe and it is defined by a simple copy assign statement,
+   return the rhs of its defining statement.  */
+
+static inline tree
+get_ssa_def_if_simple_copy (tree rhs)
+{
+  while (TREE_CODE (rhs) == SSA_NAME && !SSA_NAME_IS_DEFAULT_DEF (rhs))
+    {
+      gimple def_stmt = SSA_NAME_DEF_STMT (rhs);
+
+      if (gimple_assign_single_p (def_stmt))
+	rhs = gimple_assign_rhs1 (def_stmt);
+    }
+  return rhs;
+}
+
 /* Traverse statements from CALL backwards, scanning whether the argument ARG
    which is a member pointer is filled in with constant values.  If it is, fill
    the jump function JFUNC in appropriately.  METHOD_FIELD and DELTA_FIELD are
@@ -467,6 +483,7 @@ determine_cst_member_ptr (gimple call, tree arg, tree method_field,
       fld = TREE_OPERAND (lhs, 1);
       if (!method && fld == method_field)
 	{
+	  rhs = get_ssa_def_if_simple_copy (rhs);
 	  if (TREE_CODE (rhs) == ADDR_EXPR
 	      && TREE_CODE (TREE_OPERAND (rhs, 0)) == FUNCTION_DECL
 	      && TREE_CODE (TREE_TYPE (TREE_OPERAND (rhs, 0))) == METHOD_TYPE)
@@ -484,6 +501,7 @@ determine_cst_member_ptr (gimple call, tree arg, tree method_field,
 
       if (!delta && fld == delta_field)
 	{
+	  rhs = get_ssa_def_if_simple_copy (rhs);
 	  if (TREE_CODE (rhs) == INTEGER_CST)
 	    {
 	      delta = rhs;
diff --git a/gcc/tree-complex.c b/gcc/tree-complex.c
index 2835220c206c..3f1992b716b1 100644
--- a/gcc/tree-complex.c
+++ b/gcc/tree-complex.c
@@ -604,6 +604,7 @@ extract_component (gimple_stmt_iterator *gsi, tree t, bool imagpart_p,
     case INDIRECT_REF:
     case COMPONENT_REF:
     case ARRAY_REF:
+    case VIEW_CONVERT_EXPR:
       {
 	tree inner_type = TREE_TYPE (TREE_TYPE (t));
 
diff --git a/gcc/tree-flow-inline.h b/gcc/tree-flow-inline.h
index 6a1ae4ce7db6..e6de3772c3c0 100644
--- a/gcc/tree-flow-inline.h
+++ b/gcc/tree-flow-inline.h
@@ -1136,6 +1136,21 @@ ref_contains_array_ref (const_tree ref)
   return false;
 }
 
+/* Return true if REF has an VIEW_CONVERT_EXPR somewhere in it.  */
+
+static inline bool
+contains_view_convert_expr_p (const_tree ref)
+{
+  while (handled_component_p (ref))
+    {
+      if (TREE_CODE (ref) == VIEW_CONVERT_EXPR)
+	return true;
+      ref = TREE_OPERAND (ref, 0);
+    }
+
+  return false;
+}
+
 /* Return true, if the two ranges [POS1, SIZE1] and [POS2, SIZE2]
    overlap.  SIZE1 and/or SIZE2 can be (unsigned)-1 in which case the
    range is open-ended.  Otherwise return false.  */
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index a02eca5275b6..df14eeb22680 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -881,13 +881,6 @@ tree vn_lookup_with_vuses (tree, VEC (tree, gc) *);
 /* In tree-ssa-sink.c  */
 bool is_hidden_global_store (gimple);
 
-/* In tree-sra.c  */
-void insert_edge_copies_seq (gimple_seq, basic_block);
-void sra_insert_before (gimple_stmt_iterator *, gimple_seq);
-void sra_insert_after (gimple_stmt_iterator *, gimple_seq);
-void sra_init_cache (void);
-bool sra_type_can_be_decomposed_p (tree);
-
 /* In tree-loop-linear.c  */
 extern void linear_transform_loops (void);
 extern unsigned perfect_loop_nest_depth (struct loop *);
diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index 0c07b97c8737..5f4f5ac0b295 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -447,6 +447,26 @@ execute_mudflap_function_ops (void)
   return 0;
 }
 
+/* Insert a gimple_seq SEQ on all the outgoing edges out of BB.  Note that
+   if BB has more than one edge, STMT will be replicated for each edge.
+   Also, abnormal edges will be ignored.  */
+
+static void
+insert_edge_copies_seq (gimple_seq seq, basic_block bb)
+{
+  edge e;
+  edge_iterator ei;
+  unsigned n_copies = -1;
+
+  FOR_EACH_EDGE (e, ei, bb->succs)
+    if (!(e->flags & EDGE_ABNORMAL))
+      n_copies++;
+
+  FOR_EACH_EDGE (e, ei, bb->succs)
+    if (!(e->flags & EDGE_ABNORMAL))
+      gsi_insert_seq_on_edge (e, n_copies-- > 0 ? gimple_seq_copy (seq) : seq);
+}
+
 /* Create and initialize local shadow variables for the lookup cache
    globals.  Put their decls in the *_l globals for use by
    mf_build_check_statement_for.  */
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 626a253d1525..0f6894171637 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -236,7 +236,7 @@ is_sra_scalar_type (tree type)
    instantiated, just that if we decide to break up the type into
    separate pieces that it can be done.  */
 
-bool
+static bool
 sra_type_can_be_decomposed_p (tree type)
 {
   unsigned int cache = TYPE_UID (TYPE_MAIN_VARIANT (type)) * 2;
@@ -1267,6 +1267,26 @@ build_element_name (struct sra_elt *elt)
   return XOBFINISH (&sra_obstack, char *);
 }
 
+/* Insert a gimple_seq SEQ on all the outgoing edges out of BB.  Note that
+   if BB has more than one edge, STMT will be replicated for each edge.
+   Also, abnormal edges will be ignored.  */
+
+static void
+insert_edge_copies_seq (gimple_seq seq, basic_block bb)
+{
+  edge e;
+  edge_iterator ei;
+  unsigned n_copies = -1;
+
+  FOR_EACH_EDGE (e, ei, bb->succs)
+    if (!(e->flags & EDGE_ABNORMAL))
+      n_copies++;
+
+  FOR_EACH_EDGE (e, ei, bb->succs)
+    if (!(e->flags & EDGE_ABNORMAL))
+      gsi_insert_seq_on_edge (e, n_copies-- > 0 ? gimple_seq_copy (seq) : seq);
+}
+
 /* Instantiate an element as an independent variable.  */
 
 static void
@@ -2789,29 +2809,9 @@ generate_element_init (struct sra_elt *elt, tree init, gimple_seq *seq_p)
   return ret;
 }
 
-/* Insert a gimple_seq SEQ on all the outgoing edges out of BB.  Note that
-   if BB has more than one edge, STMT will be replicated for each edge.
-   Also, abnormal edges will be ignored.  */
-
-void
-insert_edge_copies_seq (gimple_seq seq, basic_block bb)
-{
-  edge e;
-  edge_iterator ei;
-  unsigned n_copies = -1;
-
-  FOR_EACH_EDGE (e, ei, bb->succs)
-    if (!(e->flags & EDGE_ABNORMAL)) 
-      n_copies++;
-
-  FOR_EACH_EDGE (e, ei, bb->succs)
-    if (!(e->flags & EDGE_ABNORMAL)) 
-      gsi_insert_seq_on_edge (e, n_copies-- > 0 ? gimple_seq_copy (seq) : seq);
-}
-
 /* Helper function to insert LIST before GSI, and set up line number info.  */
 
-void
+static void
 sra_insert_before (gimple_stmt_iterator *gsi, gimple_seq seq)
 {
   gimple stmt = gsi_stmt (*gsi);
@@ -2823,7 +2823,7 @@ sra_insert_before (gimple_stmt_iterator *gsi, gimple_seq seq)
 
 /* Similarly, but insert after GSI.  Handles insertion onto edges as well.  */
 
-void
+static void
 sra_insert_after (gimple_stmt_iterator *gsi, gimple_seq seq)
 {
   gimple stmt = gsi_stmt (*gsi);
@@ -3601,7 +3601,7 @@ debug_sra_elt_name (struct sra_elt *elt)
   fputc ('\n', stderr);
 }
 
-void 
+static void
 sra_init_cache (void)
 {
   if (sra_type_decomp_cache)
-- 
GitLab