OSDN Git Service

2009-07-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / alias.c
index 8a20f46..2486001 100644 (file)
@@ -128,7 +128,7 @@ along with GCC; see the file COPYING3.  If not see
    However, this is no actual entry for alias set zero.  It is an
    error to attempt to explicitly construct a subset of zero.  */
 
-struct GTY(()) alias_set_entry {
+struct GTY(()) alias_set_entry_d {
   /* The alias set number, as stored in MEM_ALIAS_SET.  */
   alias_set_type alias_set;
 
@@ -145,7 +145,7 @@ struct GTY(()) alias_set_entry {
      `int', `double', `float', and `struct S'.  */
   splay_tree GTY((param1_is (int), param2_is (int))) children;
 };
-typedef struct alias_set_entry *alias_set_entry;
+typedef struct alias_set_entry_d *alias_set_entry;
 
 static int rtx_equal_for_memref_p (const_rtx, const_rtx);
 static int memrefs_conflict_p (int, rtx, int, rtx, HOST_WIDE_INT);
@@ -155,7 +155,6 @@ static int base_alias_check (rtx, rtx, enum machine_mode,
 static rtx find_base_value (rtx);
 static int mems_in_disjoint_alias_sets_p (const_rtx, const_rtx);
 static int insert_subset_children (splay_tree_node, void*);
-static tree find_base_decl (tree);
 static alias_set_entry get_alias_set_entry (alias_set_type);
 static const_rtx fixed_scalar_and_varying_struct_p (const_rtx, const_rtx, rtx, rtx,
                                                    bool (*) (const_rtx, bool));
@@ -422,54 +421,6 @@ objects_must_conflict_p (tree t1, tree t2)
   return alias_sets_must_conflict_p (set1, set2);
 }
 \f
-/* T is an expression with pointer type.  Find the DECL on which this
-   expression is based.  (For example, in `a[i]' this would be `a'.)
-   If there is no such DECL, or a unique decl cannot be determined,
-   NULL_TREE is returned.  */
-
-static tree
-find_base_decl (tree t)
-{
-  tree d0, d1;
-
-  if (t == 0 || t == error_mark_node || ! POINTER_TYPE_P (TREE_TYPE (t)))
-    return 0;
-
-  /* If this is a declaration, return it.  If T is based on a restrict
-     qualified decl, return that decl.  */
-  if (DECL_P (t))
-    {
-      if (TREE_CODE (t) == VAR_DECL && DECL_BASED_ON_RESTRICT_P (t))
-       t = DECL_GET_RESTRICT_BASE (t);
-      return t;
-    }
-
-  /* Handle general expressions.  It would be nice to deal with
-     COMPONENT_REFs here.  If we could tell that `a' and `b' were the
-     same, then `a->f' and `b->f' are also the same.  */
-  switch (TREE_CODE_CLASS (TREE_CODE (t)))
-    {
-    case tcc_unary:
-      return find_base_decl (TREE_OPERAND (t, 0));
-
-    case tcc_binary:
-      /* Return 0 if found in neither or both are the same.  */
-      d0 = find_base_decl (TREE_OPERAND (t, 0));
-      d1 = find_base_decl (TREE_OPERAND (t, 1));
-      if (d0 == d1)
-       return d0;
-      else if (d0 == 0)
-       return d1;
-      else if (d1 == 0)
-       return d0;
-      else
-       return 0;
-
-    default:
-      return 0;
-    }
-}
-
 /* Return true if all nested component references handled by
    get_inner_reference in T are such that we should use the alias set
    provided by the object at the heart of T.
@@ -529,56 +480,9 @@ get_deref_alias_set_1 (tree t)
   if (!flag_strict_aliasing)
     return 0;
 
+  /* All we care about is the type.  */
   if (! TYPE_P (t))
-    {
-      tree decl = find_base_decl (t);
-
-      if (decl && DECL_POINTER_ALIAS_SET_KNOWN_P (decl))
-       {
-         /* If we haven't computed the actual alias set, do it now.  */
-         if (DECL_POINTER_ALIAS_SET (decl) == -2)
-           {
-             tree pointed_to_type = TREE_TYPE (TREE_TYPE (decl));
-
-             /* No two restricted pointers can point at the same thing.
-                However, a restricted pointer can point at the same thing
-                as an unrestricted pointer, if that unrestricted pointer
-                is based on the restricted pointer.  So, we make the
-                alias set for the restricted pointer a subset of the
-                alias set for the type pointed to by the type of the
-                decl.  */
-             alias_set_type pointed_to_alias_set
-                 = get_alias_set (pointed_to_type);
-
-             if (pointed_to_alias_set == 0)
-               /* It's not legal to make a subset of alias set zero.  */
-               DECL_POINTER_ALIAS_SET (decl) = 0;
-             else if (AGGREGATE_TYPE_P (pointed_to_type))
-               /* For an aggregate, we must treat the restricted
-                  pointer the same as an ordinary pointer.  If we
-                  were to make the type pointed to by the
-                  restricted pointer a subset of the pointed-to
-                  type, then we would believe that other subsets
-                  of the pointed-to type (such as fields of that
-                  type) do not conflict with the type pointed to
-                  by the restricted pointer.  */
-               DECL_POINTER_ALIAS_SET (decl)
-                   = pointed_to_alias_set;
-             else
-               {
-                 DECL_POINTER_ALIAS_SET (decl) = new_alias_set ();
-                 record_alias_subset (pointed_to_alias_set,
-                                      DECL_POINTER_ALIAS_SET (decl));
-               }
-           }
-
-         /* We use the alias set indicated in the declaration.  */
-         return DECL_POINTER_ALIAS_SET (decl);
-       }
-
-      /* Now all we care about is the type.  */
-      t = TREE_TYPE (t);
-    }
+    t = TREE_TYPE (t);
 
   /* If we have an INDIRECT_REF via a void pointer, we don't
      know anything about what that might alias.  Likewise if the
@@ -788,7 +692,7 @@ record_alias_subset (alias_set_type superset, alias_set_type subset)
     {
       /* Create an entry for the SUPERSET, so that we have a place to
         attach the SUBSET.  */
-      superset_entry = GGC_NEW (struct alias_set_entry);
+      superset_entry = GGC_NEW (struct alias_set_entry_d);
       superset_entry->alias_set = superset;
       superset_entry->children
        = splay_tree_new_ggc (splay_tree_compare_ints);
@@ -1015,9 +919,9 @@ find_base_value (rtx src)
        /* Guess which operand is the base address:
           If either operand is a symbol, then it is the base.  If
           either operand is a CONST_INT, then the other is the base.  */
-       if (GET_CODE (src_1) == CONST_INT || CONSTANT_P (src_0))
+       if (CONST_INT_P (src_1) || CONSTANT_P (src_0))
          return find_base_value (src_0);
-       else if (GET_CODE (src_0) == CONST_INT || CONSTANT_P (src_1))
+       else if (CONST_INT_P (src_0) || CONSTANT_P (src_1))
          return find_base_value (src_1);
 
        return 0;
@@ -1031,7 +935,7 @@ find_base_value (rtx src)
     case AND:
       /* If the second operand is constant set the base
         address to the first operand.  */
-      if (GET_CODE (XEXP (src, 1)) == CONST_INT && INTVAL (XEXP (src, 1)) != 0)
+      if (CONST_INT_P (XEXP (src, 1)) && INTVAL (XEXP (src, 1)) != 0)
        return find_base_value (XEXP (src, 0));
       return 0;
 
@@ -1173,7 +1077,7 @@ record_set (rtx dest, const_rtx set, void *data ATTRIBUTE_UNUSED)
          break;
        }
       case AND:
-       if (XEXP (src, 0) != dest || GET_CODE (XEXP (src, 1)) != CONST_INT)
+       if (XEXP (src, 0) != dest || !CONST_INT_P (XEXP (src, 1)))
          new_reg_base_value[regno] = 0;
        break;
       default:
@@ -1266,9 +1170,9 @@ canon_rtx (rtx x)
 
       if (x0 != XEXP (x, 0) || x1 != XEXP (x, 1))
        {
-         if (GET_CODE (x0) == CONST_INT)
+         if (CONST_INT_P (x0))
            return plus_constant (x1, INTVAL (x0));
-         else if (GET_CODE (x1) == CONST_INT)
+         else if (CONST_INT_P (x1))
            return plus_constant (x0, INTVAL (x1));
          return gen_rtx_PLUS (GET_MODE (x), x0, x1);
        }
@@ -1508,10 +1412,18 @@ find_base_term (rtx x)
        /* If either operand is known to be a pointer, then use it
           to determine the base term.  */
        if (REG_P (tmp1) && REG_POINTER (tmp1))
-         return find_base_term (tmp1);
+         {
+           rtx base = find_base_term (tmp1);
+           if (base)
+             return base;
+         }
 
        if (REG_P (tmp2) && REG_POINTER (tmp2))
-         return find_base_term (tmp2);
+         {
+           rtx base = find_base_term (tmp2);
+           if (base)
+             return base;
+         }
 
        /* Neither operand was known to be a pointer.  Go ahead and find the
           base term for both operands.  */
@@ -1542,7 +1454,7 @@ find_base_term (rtx x)
       }
 
     case AND:
-      if (GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) != 0)
+      if (CONST_INT_P (XEXP (x, 1)) && INTVAL (XEXP (x, 1)) != 0)
        return find_base_term (XEXP (x, 0));
       return 0;
 
@@ -1605,11 +1517,11 @@ base_alias_check (rtx x, rtx y, enum machine_mode x_mode,
   if (GET_CODE (x) == AND && GET_CODE (y) == AND)
     return 1;
   if (GET_CODE (x) == AND
-      && (GET_CODE (XEXP (x, 1)) != CONST_INT
+      && (!CONST_INT_P (XEXP (x, 1))
          || (int) GET_MODE_UNIT_SIZE (y_mode) < -INTVAL (XEXP (x, 1))))
     return 1;
   if (GET_CODE (y) == AND
-      && (GET_CODE (XEXP (y, 1)) != CONST_INT
+      && (!CONST_INT_P (XEXP (y, 1))
          || (int) GET_MODE_UNIT_SIZE (x_mode) < -INTVAL (XEXP (y, 1))))
     return 1;
 
@@ -1770,21 +1682,21 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c)
            return memrefs_conflict_p (xsize, x0, ysize, y0, c);
          if (rtx_equal_for_memref_p (x0, y0))
            return memrefs_conflict_p (xsize, x1, ysize, y1, c);
-         if (GET_CODE (x1) == CONST_INT)
+         if (CONST_INT_P (x1))
            {
-             if (GET_CODE (y1) == CONST_INT)
+             if (CONST_INT_P (y1))
                return memrefs_conflict_p (xsize, x0, ysize, y0,
                                           c - INTVAL (x1) + INTVAL (y1));
              else
                return memrefs_conflict_p (xsize, x0, ysize, y,
                                           c - INTVAL (x1));
            }
-         else if (GET_CODE (y1) == CONST_INT)
+         else if (CONST_INT_P (y1))
            return memrefs_conflict_p (xsize, x, ysize, y0, c + INTVAL (y1));
 
          return 1;
        }
-      else if (GET_CODE (x1) == CONST_INT)
+      else if (CONST_INT_P (x1))
        return memrefs_conflict_p (xsize, x0, ysize, y, c - INTVAL (x1));
     }
   else if (GET_CODE (y) == PLUS)
@@ -1794,7 +1706,7 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c)
       rtx y0 = XEXP (y, 0);
       rtx y1 = XEXP (y, 1);
 
-      if (GET_CODE (y1) == CONST_INT)
+      if (CONST_INT_P (y1))
        return memrefs_conflict_p (xsize, x, ysize, y0, c + INTVAL (y1));
       else
        return 1;
@@ -1820,7 +1732,7 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c)
                    || (c >= 0 && xsize > c) || (c < 0 && ysize+c > 0));
 
          /* Can't properly adjust our sizes.  */
-         if (GET_CODE (x1) != CONST_INT)
+         if (!CONST_INT_P (x1))
            return 1;
          xsize /= INTVAL (x1);
          ysize /= INTVAL (x1);
@@ -1836,13 +1748,13 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c)
      as an access with indeterminate size.  Assume that references
      besides AND are aligned, so if the size of the other reference is
      at least as large as the alignment, assume no other overlap.  */
-  if (GET_CODE (x) == AND && GET_CODE (XEXP (x, 1)) == CONST_INT)
+  if (GET_CODE (x) == AND && CONST_INT_P (XEXP (x, 1)))
     {
       if (GET_CODE (y) == AND || ysize < -INTVAL (XEXP (x, 1)))
        xsize = -1;
       return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)), ysize, y, c);
     }
-  if (GET_CODE (y) == AND && GET_CODE (XEXP (y, 1)) == CONST_INT)
+  if (GET_CODE (y) == AND && CONST_INT_P (XEXP (y, 1)))
     {
       /* ??? If we are indexing far enough into the array/structure, we
         may yet be able to determine that we can not overlap.  But we
@@ -1855,7 +1767,7 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c)
 
   if (CONSTANT_P (x))
     {
-      if (GET_CODE (x) == CONST_INT && GET_CODE (y) == CONST_INT)
+      if (CONST_INT_P (x) && CONST_INT_P (y))
        {
          c += (INTVAL (y) - INTVAL (x));
          return (xsize <= 0 || ysize <= 0
@@ -2158,11 +2070,11 @@ nonoverlapping_memrefs_p (const_rtx x, const_rtx y)
      we can avoid overlap is if we can deduce that they are nonoverlapping
      pieces of that decl, which is very rare.  */
   basex = MEM_P (rtlx) ? XEXP (rtlx, 0) : rtlx;
-  if (GET_CODE (basex) == PLUS && GET_CODE (XEXP (basex, 1)) == CONST_INT)
+  if (GET_CODE (basex) == PLUS && CONST_INT_P (XEXP (basex, 1)))
     offsetx = INTVAL (XEXP (basex, 1)), basex = XEXP (basex, 0);
 
   basey = MEM_P (rtly) ? XEXP (rtly, 0) : rtly;
-  if (GET_CODE (basey) == PLUS && GET_CODE (XEXP (basey, 1)) == CONST_INT)
+  if (GET_CODE (basey) == PLUS && CONST_INT_P (XEXP (basey, 1)))
     offsety = INTVAL (XEXP (basey, 1)), basey = XEXP (basey, 0);
 
   /* If the bases are different, we know they do not overlap if both
@@ -2370,9 +2282,6 @@ write_dependence_p (const_rtx mem, const_rtx x, int writep)
       || MEM_ALIAS_SET (mem) == ALIAS_SET_MEMORY_BARRIER)
     return 1;
 
-  if (DIFFERENT_ALIAS_SETS_P (x, mem))
-    return 0;
-
   /* A read from read-only memory can't conflict with read-write memory.  */
   if (!writep && MEM_READONLY_P (mem))
     return 0;
@@ -2619,7 +2528,7 @@ init_alias_analysis (void)
                           && GET_CODE (src) == PLUS
                           && REG_P (XEXP (src, 0))
                           && (t = get_reg_known_value (REGNO (XEXP (src, 0))))
-                          && GET_CODE (XEXP (src, 1)) == CONST_INT)
+                          && CONST_INT_P (XEXP (src, 1)))
                    {
                      t = plus_constant (t, INTVAL (XEXP (src, 1)));
                      set_reg_known_value (regno, t);