OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / tree-vn.c
index 1afd0fe..0c5061f 100644 (file)
@@ -1,5 +1,5 @@
 /* Value Numbering routines for tree expressions.
-   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
    Contributed by Daniel Berlin <dan@dberlin.org>, Steven Bosscher
    <stevenb@suse.de> and Diego Novillo <dnovillo@redhat.com>
 
@@ -7,7 +7,7 @@ This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GCC is distributed in the hope that it will be useful,
@@ -16,9 +16,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
@@ -60,7 +59,7 @@ bool
 expressions_equal_p (tree e1, tree e2)
 {
   tree te1, te2;
-  
+
   if (e1 == e2)
     return true;
 
@@ -84,10 +83,6 @@ expressions_equal_p (tree e1, tree e2)
 
     }
   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) 
           && (te1 == te2
               || types_compatible_p (te1, te2))
           && operand_equal_p (e1, e2, OEP_PURE_SAME))
@@ -97,18 +92,13 @@ expressions_equal_p (tree e1, tree e2)
 }
 
 /* Set the value handle for expression E to value V.  */
-   
+
 void
 set_value_handle (tree e, tree v)
 {
   if (TREE_CODE (e) == SSA_NAME)
     SSA_NAME_VALUE (e) = v;
-  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
+  else if (EXPR_P (e) || DECL_P (e) || TREE_CODE (e) == TREE_LIST
           || GIMPLE_STMT_P (e)
           || TREE_CODE (e) == CONSTRUCTOR)
     get_tree_common_ann (e)->value_handle = v;
@@ -117,22 +107,6 @@ set_value_handle (tree e, tree v)
     gcc_assert (is_gimple_min_invariant (e));
 }
 
-
-
-
-/* A comparison function for use in qsort to compare vuses.  Simply
-   subtracts version numbers.  */
-
-static int
-vuses_compare (const void *pa, const void *pb)
-{
-  const tree vusea = *((const tree *)pa);
-  const tree vuseb = *((const tree *)pb);
-  int sn = SSA_NAME_VERSION (vusea) - SSA_NAME_VERSION (vuseb);
-
-  return sn;
-}
-
 /* Print out the "Created value <x> for <Y>" statement to the
    dump_file.
    This is factored because both versions of lookup use it, and it
@@ -145,12 +119,12 @@ print_creation_to_file (tree v, tree expr, VEC (tree, gc) *vuses)
   print_generic_expr (dump_file, v, dump_flags);
   fprintf (dump_file, " for ");
   print_generic_expr (dump_file, expr, dump_flags);
-  
+
   if (vuses && VEC_length (tree, vuses) != 0)
     {
       size_t i;
       tree vuse;
-      
+
       fprintf (dump_file, " vuses: (");
       for (i = 0; VEC_iterate (tree, vuses, i, vuse); i++)
        {
@@ -159,7 +133,7 @@ print_creation_to_file (tree v, tree expr, VEC (tree, gc) *vuses)
            fprintf (dump_file, ",");
        }
       fprintf (dump_file, ")");
-    }             
+    }
   fprintf (dump_file, "\n");
 }
 
@@ -167,27 +141,27 @@ print_creation_to_file (tree v, tree expr, VEC (tree, gc) *vuses)
 /* Sort the VUSE array so that we can do equality comparisons
    quicker on two vuse vecs.  */
 
-void 
+void
 sort_vuses (VEC (tree,gc) *vuses)
 {
   if (VEC_length (tree, vuses) > 1)
     qsort (VEC_address (tree, vuses),
           VEC_length (tree, vuses),
           sizeof (tree),
-          vuses_compare);
+          operand_build_cmp);
 }
 
 /* Sort the VUSE array so that we can do equality comparisons
    quicker on two vuse vecs.  */
 
-void 
+void
 sort_vuses_heap (VEC (tree,heap) *vuses)
 {
   if (VEC_length (tree, vuses) > 1)
     qsort (VEC_address (tree, vuses),
           VEC_length (tree, vuses),
           sizeof (tree),
-          vuses_compare);
+          operand_build_cmp);
 }
 /* Insert EXPR into VALUE_TABLE with value VAL, and add expression
    EXPR to the value set for value VAL.  */
@@ -292,7 +266,7 @@ vn_lookup (tree expr)
       if (TREE_CODE (expr) == CALL_EXPR || DECL_P (expr))
        return vn_reference_lookup (expr, NULL);
       else if (TREE_CODE (expr) == SSA_NAME)
-       return SSA_NAME_VALUE (expr);      
+       return SSA_NAME_VALUE (expr);
       else if (TREE_CODE (expr) == ADDR_EXPR)
        return vn_unary_op_lookup (expr);
       /* FALLTHROUGH */
@@ -304,7 +278,7 @@ vn_lookup (tree expr)
 
 /* Search in the value numbering tables for an existing instance of
    expression EXPR,  and return its value, or NULL if none has been set.  STMT
-   represents the stmt associated with EXPR.  It is used when computing the 
+   represents the stmt associated with EXPR.  It is used when computing the
    hash value for EXPR for reference operations.  */
 
 tree
@@ -338,16 +312,14 @@ vn_lookup_with_vuses (tree expr, VEC (tree, gc) *vuses)
 }
 
 static tree
-create_value_handle_for_expr (tree expr, VEC (tree, gc) *vuses)
+create_value_handle_for_expr (tree expr, VEC(tree, gc) *vuses)
 {
   tree v;
-  
+
   v = make_value_handle (TREE_TYPE (expr));
-  
+
   if (dump_file && (dump_flags & TDF_DETAILS))
     print_creation_to_file (v, expr, vuses);
-  if (vuses)
-    VALUE_HANDLE_VUSES (v) = vuses;
   return v;
 }
 
@@ -358,7 +330,7 @@ tree
 vn_lookup_or_add (tree expr)
 {
   tree v = vn_lookup (expr);
-  
+
   if (v == NULL_TREE)
     {
       v = create_value_handle_for_expr (expr, NULL);
@@ -402,10 +374,10 @@ tree
 vn_lookup_or_add_with_vuses (tree expr, VEC (tree, gc) *vuses)
 {
   tree v;
-  
+
   if (!vuses || VEC_length (tree, vuses) == 0)
     return vn_lookup_or_add (expr);
-  
+
   v = vn_lookup_with_vuses (expr, vuses);
   if (v == NULL_TREE)
     {