OSDN Git Service

2010-04-07 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Apr 2010 15:31:37 +0000 (15:31 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Apr 2010 15:31:37 +0000 (15:31 +0000)
* ipa-reference.c (mark_load): Use get_base_address.
(mark_store): Likewise.

* tree-ssa-ccp.c (gimplify_and_update_call_from_tree): Avoid
inserting GIMPLE_NOPs into the IL.
* tree-ssa-structalias.c (get_constraint_for_component_ref):
Explicitly strip handled components and indirect references.

* fold-const.c (fold_unary_loc): Do not strip qualifiers when
folding address expressions.
* gimple.c (gimple_ior_addresses_taken_1): Use get_base_address.
* tree-ssa-alias.c (decl_refs_may_alias_p): Do not use
operand_equal_p to compare decls.
(ptr_deref_may_alias_decl_p): Likewise.
* tree-ssa-operands.c (get_asm_expr_operands): Simplify
* tree-ssa-forwprop.c (forward_propagate_into_gimple_cond):
Handle reversed comparison ops.
* tree-sra.c (asm_visit_addr): Use get_base_address.
* ipa-prop.c (visit_store_addr_for_mod_analysis): Use
get_base_address.
* ipa-reference.c (mark_address): Use get_base_address.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158069 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/gimple.c
gcc/ipa-prop.c
gcc/ipa-reference.c
gcc/tree-sra.c
gcc/tree-ssa-alias.c
gcc/tree-ssa-ccp.c
gcc/tree-ssa-forwprop.c
gcc/tree-ssa-operands.c
gcc/tree-ssa-structalias.c

index 20aa611..693d69d 100644 (file)
@@ -1,5 +1,29 @@
 2010-04-07  Richard Guenther  <rguenther@suse.de>
 
+       * ipa-reference.c (mark_load): Use get_base_address.
+       (mark_store): Likewise.
+
+       * tree-ssa-ccp.c (gimplify_and_update_call_from_tree): Avoid
+       inserting GIMPLE_NOPs into the IL.
+       * tree-ssa-structalias.c (get_constraint_for_component_ref):
+       Explicitly strip handled components and indirect references.
+  
+       * fold-const.c (fold_unary_loc): Do not strip qualifiers when
+       folding address expressions.
+       * gimple.c (gimple_ior_addresses_taken_1): Use get_base_address.
+       * tree-ssa-alias.c (decl_refs_may_alias_p): Do not use
+       operand_equal_p to compare decls.
+       (ptr_deref_may_alias_decl_p): Likewise.
+       * tree-ssa-operands.c (get_asm_expr_operands): Simplify
+       * tree-ssa-forwprop.c (forward_propagate_into_gimple_cond):
+       Handle reversed comparison ops.
+       * tree-sra.c (asm_visit_addr): Use get_base_address.
+       * ipa-prop.c (visit_store_addr_for_mod_analysis): Use
+       get_base_address.
+       * ipa-reference.c (mark_address): Use get_base_address.
+
+2010-04-07  Richard Guenther  <rguenther@suse.de>
+
        * tree-ssa-forwprop.c (forward_propagate_addr_expr):
        Propagate constants everywhere.
 
index 62c8625..03598a5 100644 (file)
@@ -8561,10 +8561,11 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
                                      &mode, &unsignedp, &volatilep, false);
          /* If the reference was to a (constant) zero offset, we can use
             the address of the base if it has the same base type
-            as the result type.  */
+            as the result type and the pointer type is unqualified.  */
          if (! offset && bitpos == 0
-             && TYPE_MAIN_VARIANT (TREE_TYPE (type))
+             && (TYPE_MAIN_VARIANT (TREE_TYPE (type))
                  == TYPE_MAIN_VARIANT (TREE_TYPE (base)))
+             && TYPE_QUALS (type) == TYPE_UNQUALIFIED)
            return fold_convert_loc (loc, type,
                                     build_fold_addr_expr_loc (loc, base));
         }
index 717a020..ae0be4e 100644 (file)
@@ -4532,9 +4532,9 @@ gimple_ior_addresses_taken_1 (gimple stmt ATTRIBUTE_UNUSED,
                              tree addr, void *data)
 {
   bitmap addresses_taken = (bitmap)data;
-  while (handled_component_p (addr))
-    addr = TREE_OPERAND (addr, 0);
-  if (DECL_P (addr))
+  addr = get_base_address (addr);
+  if (addr
+      && DECL_P (addr))
     {
       bitmap_set_bit (addresses_taken, DECL_UID (addr));
       return true;
index a3ab8b3..82a78a3 100644 (file)
@@ -199,7 +199,9 @@ visit_store_addr_for_mod_analysis (gimple stmt ATTRIBUTE_UNUSED,
 {
   struct ipa_node_params *info = (struct ipa_node_params *) data;
 
-  if (TREE_CODE (op) == PARM_DECL)
+  op = get_base_address (op);
+  if (op
+      && TREE_CODE (op) == PARM_DECL)
     {
       int index = ipa_get_param_decl_index (info, op);
       gcc_assert (index >= 0);
index cc790fd..9eac3b1 100644 (file)
@@ -352,9 +352,9 @@ static bool
 mark_address (gimple stmt ATTRIBUTE_UNUSED, tree addr,
              void *data ATTRIBUTE_UNUSED)
 {
-  while (handled_component_p (addr))
-    addr = TREE_OPERAND (addr, 0);
-  mark_address_taken (addr);
+  addr = get_base_address (addr);
+  if (addr)
+    mark_address_taken (addr);
   return false;
 }
 
@@ -364,7 +364,8 @@ static bool
 mark_load (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
 {
   ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
-  if (TREE_CODE (t) == VAR_DECL
+  t = get_base_address (t);
+  if (t && TREE_CODE (t) == VAR_DECL
       && has_proper_scope_for_analysis (t))
     bitmap_set_bit (local->statics_read, DECL_UID (t));
   return false;
@@ -376,7 +377,8 @@ static bool
 mark_store (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
 {
   ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
-  if (TREE_CODE (t) == VAR_DECL
+  t = get_base_address (t);
+  if (t && TREE_CODE (t) == VAR_DECL
       && has_proper_scope_for_analysis (t))
     {
       if (local)
index d4adb61..5653168 100644 (file)
@@ -1066,7 +1066,9 @@ static bool
 asm_visit_addr (gimple stmt ATTRIBUTE_UNUSED, tree op,
                void *data ATTRIBUTE_UNUSED)
 {
-  if (DECL_P (op))
+  op = get_base_address (op);
+  if (op
+      && DECL_P (op))
     disqualify_candidate (op, "Non-scalarizable GIMPLE_ASM operand.");
 
   return false;
index 47d611c..282148c 100644 (file)
@@ -189,7 +189,7 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl)
        ptr = TREE_OPERAND (base, 0);
       else if (base
               && SSA_VAR_P (base))
-       return operand_equal_p (base, decl, 0);
+       return base == decl;
       else if (base
               && CONSTANT_CLASS_P (base))
        return false;
@@ -629,7 +629,7 @@ decl_refs_may_alias_p (tree base1,
   gcc_assert (SSA_VAR_P (base1) && SSA_VAR_P (base2));
 
   /* If both references are based on different variables, they cannot alias.  */
-  if (!operand_equal_p (base1, base2, 0))
+  if (base1 != base2)
     return false;
 
   /* If both references are based on the same variable, they cannot alias if
index fcfdd18..f0106eb 100644 (file)
@@ -3354,6 +3354,7 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
   gimple_stmt_iterator i;
   gimple_seq stmts = gimple_seq_alloc();
   struct gimplify_ctx gctx;
+  gimple last = NULL;
 
   stmt = gsi_stmt (*si_p);
 
@@ -3375,22 +3376,31 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
 
   /* The replacement can expose previously unreferenced variables.  */
   for (i = gsi_start (stmts); !gsi_end_p (i); gsi_next (&i))
-  {
-    new_stmt = gsi_stmt (i);
-    find_new_referenced_vars (new_stmt);
-    gsi_insert_before (si_p, new_stmt, GSI_NEW_STMT);
-    mark_symbols_for_renaming (new_stmt);
-    gsi_next (si_p);
-  }
+    {
+      if (last)
+       {
+         gsi_insert_before (si_p, last, GSI_NEW_STMT);
+         gsi_next (si_p);
+       }
+      new_stmt = gsi_stmt (i);
+      find_new_referenced_vars (new_stmt);
+      mark_symbols_for_renaming (new_stmt);
+      last = new_stmt;
+    }
 
   if (lhs == NULL_TREE)
     {
-      new_stmt = gimple_build_nop ();
       unlink_stmt_vdef (stmt);
       release_defs (stmt);
+      new_stmt = last;
     }
   else
     {
+      if (last)
+       {
+         gsi_insert_before (si_p, last, GSI_NEW_STMT);
+         gsi_next (si_p);
+       }
       new_stmt = gimple_build_assign (lhs, tmp);
       gimple_set_vuse (new_stmt, gimple_vuse (stmt));
       gimple_set_vdef (new_stmt, gimple_vdef (stmt));
index d7d378b..fc40bf4 100644 (file)
@@ -398,25 +398,27 @@ forward_propagate_into_gimple_cond (gimple stmt)
 
   do {
     tree tmp = NULL_TREE;
-    tree name, rhs0 = NULL_TREE, rhs1 = NULL_TREE;
+    tree name = NULL_TREE, rhs0 = NULL_TREE, rhs1 = NULL_TREE;
     gimple def_stmt;
     bool single_use0_p = false, single_use1_p = false;
     enum tree_code code = gimple_cond_code (stmt);
 
     /* We can do tree combining on SSA_NAME and comparison expressions.  */
-    if (TREE_CODE_CLASS (gimple_cond_code (stmt)) == tcc_comparison
-        && TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME)
+    if (TREE_CODE_CLASS (gimple_cond_code (stmt)) == tcc_comparison)
       {
        /* For comparisons use the first operand, that is likely to
           simplify comparisons against constants.  */
-       name = gimple_cond_lhs (stmt);
-       def_stmt = get_prop_source_stmt (name, false, &single_use0_p);
-       if (def_stmt && can_propagate_from (def_stmt))
+       if (TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME)
          {
-           tree op1 = gimple_cond_rhs (stmt);
-           rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt);
-           tmp = combine_cond_expr_cond (loc, code, boolean_type_node, rhs0,
-                                         op1, !single_use0_p);
+           name = gimple_cond_lhs (stmt);
+           def_stmt = get_prop_source_stmt (name, false, &single_use0_p);
+           if (def_stmt && can_propagate_from (def_stmt))
+             {
+               tree op1 = gimple_cond_rhs (stmt);
+               rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt);
+               tmp = combine_cond_expr_cond (loc, code, boolean_type_node,
+                                             rhs0, op1, !single_use0_p);
+             }
          }
        /* If that wasn't successful, try the second operand.  */
        if (tmp == NULL_TREE
index de2985f..cd8b6f8 100644 (file)
@@ -798,11 +798,7 @@ get_asm_expr_operands (gimple stmt)
       /* Memory operands are addressable.  Note that STMT needs the
         address of this operand.  */
       if (!allows_reg && allows_mem)
-       {
-         tree t = get_base_address (TREE_VALUE (link));
-         if (t && DECL_P (t))
-           mark_address_taken (t);
-       }
+       mark_address_taken (TREE_VALUE (link));
 
       get_expr_operands (stmt, &TREE_VALUE (link), opf_def);
     }
@@ -818,11 +814,7 @@ get_asm_expr_operands (gimple stmt)
       /* Memory operands are addressable.  Note that STMT needs the
         address of this operand.  */
       if (!allows_reg && allows_mem)
-       {
-         tree t = get_base_address (TREE_VALUE (link));
-         if (t && DECL_P (t))
-           mark_address_taken (t);
-       }
+       mark_address_taken (TREE_VALUE (link));
 
       get_expr_operands (stmt, &TREE_VALUE (link), 0);
     }
index 1516634..2384099 100644 (file)
@@ -2951,7 +2951,8 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
   /* Some people like to do cute things like take the address of
      &0->a.b */
   forzero = t;
-  while (!SSA_VAR_P (forzero) && !CONSTANT_CLASS_P (forzero))
+  while (handled_component_p (forzero)
+        || INDIRECT_REF_P (forzero))
     forzero = TREE_OPERAND (forzero, 0);
 
   if (CONSTANT_CLASS_P (forzero) && integer_zerop (forzero))