Richi has asked the we break the wide-int patch so that the individual port and 
front end maintainers can review their parts without have to go through the 
entire patch.    This patch covers the alias analysis code.

Ok?

        * alias.c
        (ao_ref_from_mem): Use wide-int interfaces.
        (rtx_equal_for_memref_p): Update comment.
        (adjust_offset_for_component_ref): Use wide-int interfaces.


diff --git a/gcc/alias.c b/gcc/alias.c
index daa667c..8a1f09b 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -340,9 +340,10 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem)
   if (MEM_EXPR (mem) != get_spill_slot_decl (false)
       && (ref->offset < 0
          || (DECL_P (ref->base)
-             && (!tree_fits_uhwi_p (DECL_SIZE (ref->base))
-                 || (tree_to_uhwi (DECL_SIZE (ref->base))
-                     < (unsigned HOST_WIDE_INT) (ref->offset + ref->size))))))
+             && (DECL_SIZE (ref->base) == NULL_TREE
+                 || TREE_CODE (DECL_SIZE (ref->base)) != INTEGER_CST
+                 || wi::ltu_p (DECL_SIZE (ref->base),
+                               ref->offset + ref->size)))))
     return false;
 
   return true;
@@ -1543,9 +1544,7 @@ rtx_equal_for_memref_p (const_rtx x, const_rtx y)
 
     case VALUE:
     CASE_CONST_UNIQUE:
-      /* There's no need to compare the contents of CONST_DOUBLEs or
-        CONST_INTs because pointer equality is a good enough
-        comparison for these nodes.  */
+      /* Pointer equality guarantees equality for these nodes.  */
       return 0;
 
     default:
@@ -2348,15 +2347,22 @@ adjust_offset_for_component_ref (tree x, bool *known_p,
     {
       tree xoffset = component_ref_field_offset (x);
       tree field = TREE_OPERAND (x, 1);
+      if (TREE_CODE (xoffset) != INTEGER_CST)
+       {
+         *known_p = false;
+         return;
+       }
 
-      if (! tree_fits_uhwi_p (xoffset))
+      offset_int woffset
+       = (wi::to_offset (xoffset)
+          + wi::udiv_trunc (wi::to_offset (DECL_FIELD_BIT_OFFSET (field)),
+                            BITS_PER_UNIT));
+      if (!wi::fits_uhwi_p (woffset))
        {
          *known_p = false;
          return;
        }
-      *offset += (tree_to_uhwi (xoffset)
-                 + (tree_to_uhwi (DECL_FIELD_BIT_OFFSET (field))
-                    / BITS_PER_UNIT));
+      *offset += woffset.to_uhwi ();
 
       x = TREE_OPERAND (x, 0);
     }

Reply via email to