This is probably the only non-obvious part of the series.  I went through
all callers to tree_to_uhwi to see whether they were used in a context
where signedness mattered.  If so, I tried to adjust the casting to match.

This mostly meant removing casts to unsigned types.  There are a couple
of cases where I added casts to HOST_WIDE_INT though, to mimic the old
tree_low_cst behaviour:

- In cfgexpand.c and trans-mem.c, where we're comparing the value
  with an int PARAM_VALUE.  The test isn't watertight since any
  unsigned constant > HOST_WIDE_INT_MAX is going to be accepted.
  That's a preexisting problem though and it can be fixed more
  easily with wi:: routines.  Until then this preserves the current
  behaviour.

- In the AArch32/64 and powerpc ABI handling.  Here too "count"
  is an int and is probably not safe for large values anyway; e.g.:

        count *= (1 + tree_to_uhwi (TYPE_MAX_VALUE (index))
                      - tree_to_uhwi (TYPE_MIN_VALUE (index)));

  is done without overflow checking.  This too is easier to fix
  with wi::, so I've just kept it as a signed comparison for now.

Thanks,
Richard


gcc/c-family/
        * c-common.c (convert_vector_to_pointer_for_subscript): Remove
        cast to unsigned type.

gcc/
        * tree.h (tree_to_uhwi): Return an unsigned HOST_WIDE_INT.
        * tree.c (tree_to_uhwi): Return an unsigned HOST_WIDE_INT.
        (tree_ctz): Remove cast to unsigned type.
        * builtins.c (fold_builtin_memory_op): Likewise.
        * dwarf2out.c (descr_info_loc): Likewise.
        * godump.c (go_output_typedef): Likewise.
        * omp-low.c (expand_omp_simd): Likewise.
        * stor-layout.c (excess_unit_span): Likewise.
        * tree-object-size.c (addr_object_size): Likewise.
        * tree-sra.c (analyze_all_variable_accesses): Likewise.
        * tree-ssa-forwprop.c (simplify_builtin_call): Likewise.
        (simplify_rotate): Likewise.
        * tree-ssa-strlen.c (adjust_last_stmt, handle_builtin_memcpy)
        (handle_pointer_plus): Likewise.
        * tree-switch-conversion.c (check_range): Likewise.
        * tree-vect-patterns.c (vect_recog_rotate_pattern): Likewise.
        * tsan.c (instrument_builtin_call): Likewise.
        * cfgexpand.c (defer_stack_allocation): Add cast to HOST_WIDE_INT.
        * trans-mem.c (tm_log_add): Likewise.
        * config/aarch64/aarch64.c (aapcs_vfp_sub_candidate): Likewise.
        * config/arm/arm.c (aapcs_vfp_sub_candidate): Likewise.
        * config/rs6000/rs6000.c (rs6000_aggregate_candidate): Likewise.
        * config/mips/mips.c (r10k_safe_mem_expr_p): Make offset unsigned.

Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c     2013-11-16 10:13:53.825800713 +0000
+++ gcc/c-family/c-common.c     2013-11-16 10:14:40.373263297 +0000
@@ -11702,8 +11702,7 @@ convert_vector_to_pointer_for_subscript
 
       if (TREE_CODE (index) == INTEGER_CST)
         if (!tree_fits_uhwi_p (index)
-            || ((unsigned HOST_WIDE_INT) tree_to_uhwi (index)
-               >= TYPE_VECTOR_SUBPARTS (type)))
+            || tree_to_uhwi (index) >= TYPE_VECTOR_SUBPARTS (type))
           warning_at (loc, OPT_Warray_bounds, "index value is out of bound");
 
       c_common_mark_addressable_vec (*vecp);
Index: gcc/tree.h
===================================================================
--- gcc/tree.h  2013-11-16 10:14:00.618868694 +0000
+++ gcc/tree.h  2013-11-16 10:14:40.488264431 +0000
@@ -3665,7 +3665,7 @@ extern bool tree_fits_uhwi_p (const_tree
 #endif
   ;
 extern HOST_WIDE_INT tree_to_shwi (const_tree);
-extern HOST_WIDE_INT tree_to_uhwi (const_tree);
+extern unsigned HOST_WIDE_INT tree_to_uhwi (const_tree);
 #if !defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 4003)
 extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT
 tree_to_shwi (const_tree t)
@@ -3674,7 +3674,7 @@ tree_to_shwi (const_tree t)
   return TREE_INT_CST_LOW (t);
 }
 
-extern inline __attribute__ ((__gnu_inline__)) HOST_WIDE_INT
+extern inline __attribute__ ((__gnu_inline__)) unsigned HOST_WIDE_INT
 tree_to_uhwi (const_tree t)
 {
   gcc_assert (tree_fits_uhwi_p (t));
Index: gcc/tree.c
===================================================================
--- gcc/tree.c  2013-11-16 10:14:00.604868554 +0000
+++ gcc/tree.c  2013-11-16 10:14:40.488264431 +0000
@@ -2211,8 +2211,7 @@ tree_ctz (const_tree expr)
     case LSHIFT_EXPR:
       ret1 = tree_ctz (TREE_OPERAND (expr, 0));
       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
-         && ((unsigned HOST_WIDE_INT) tree_to_uhwi (TREE_OPERAND (expr, 1))
-             < (unsigned HOST_WIDE_INT) prec))
+         && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
        {
          ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
          return MIN (ret1 + ret2, prec);
@@ -2220,8 +2219,7 @@ tree_ctz (const_tree expr)
       return ret1;
     case RSHIFT_EXPR:
       if (tree_fits_uhwi_p (TREE_OPERAND (expr, 1))
-         && ((unsigned HOST_WIDE_INT) tree_to_uhwi (TREE_OPERAND (expr, 1))
-             < (unsigned HOST_WIDE_INT) prec))
+         && (tree_to_uhwi (TREE_OPERAND (expr, 1)) < prec))
        {
          ret1 = tree_ctz (TREE_OPERAND (expr, 0));
          ret2 = tree_to_uhwi (TREE_OPERAND (expr, 1));
@@ -7011,7 +7009,7 @@ tree_to_shwi (const_tree t)
    TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  Return that
    HOST_WIDE_INT.  */
 
-HOST_WIDE_INT
+unsigned HOST_WIDE_INT
 tree_to_uhwi (const_tree t)
 {
   gcc_assert (tree_fits_uhwi_p (t));
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c      2013-11-16 09:59:36.224612331 +0000
+++ gcc/builtins.c      2013-11-16 10:14:40.370263268 +0000
@@ -8728,7 +8728,7 @@ fold_builtin_memory_op (location_t loc,
          if (readonly_data_expr (src)
              || (tree_fits_uhwi_p (len)
                  && (MIN (src_align, dest_align) / BITS_PER_UNIT
-                     >= (unsigned HOST_WIDE_INT) tree_to_uhwi (len))))
+                     >= tree_to_uhwi (len))))
            {
              tree fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
              if (!fn)
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c     2013-11-16 09:59:36.839617357 +0000
+++ gcc/dwarf2out.c     2013-11-16 10:14:40.480264352 +0000
@@ -17073,8 +17073,7 @@ descr_info_loc (tree val, tree base_decl
     case POINTER_PLUS_EXPR:
     case PLUS_EXPR:
       if (tree_fits_uhwi_p (TREE_OPERAND (val, 1))
-         && (unsigned HOST_WIDE_INT) tree_to_uhwi (TREE_OPERAND (val, 1))
-            < 16384)
+         && tree_to_uhwi (TREE_OPERAND (val, 1)) < 16384)
        {
          loc = descr_info_loc (TREE_OPERAND (val, 0), base_decl);
          if (!loc)
Index: gcc/godump.c
===================================================================
--- gcc/godump.c        2013-11-16 09:59:36.904617888 +0000
+++ gcc/godump.c        2013-11-16 10:14:40.481264362 +0000
@@ -986,8 +986,7 @@ go_output_typedef (struct godump_contain
                     tree_to_shwi (TREE_VALUE (element)));
          else if (tree_fits_uhwi_p (TREE_VALUE (element)))
            snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_UNSIGNED,
-                    ((unsigned HOST_WIDE_INT)
-                     tree_to_uhwi (TREE_VALUE (element))));
+                     tree_to_uhwi (TREE_VALUE (element)));
          else
            snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
                     ((unsigned HOST_WIDE_INT)
Index: gcc/omp-low.c
===================================================================
--- gcc/omp-low.c       2013-11-16 09:59:36.999618664 +0000
+++ gcc/omp-low.c       2013-11-16 10:14:40.482264372 +0000
@@ -6769,8 +6769,7 @@ expand_omp_simd (struct omp_region *regi
        {
          safelen = OMP_CLAUSE_SAFELEN_EXPR (safelen);
          if (!tree_fits_uhwi_p (safelen)
-             || (unsigned HOST_WIDE_INT) tree_to_uhwi (safelen)
-                > INT_MAX)
+             || tree_to_uhwi (safelen) > INT_MAX)
            loop->safelen = INT_MAX;
          else
            loop->safelen = tree_to_uhwi (safelen);
Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c   2013-11-16 09:59:37.020618836 +0000
+++ gcc/stor-layout.c   2013-11-16 10:14:40.483264382 +0000
@@ -1053,8 +1053,7 @@ excess_unit_span (HOST_WIDE_INT byte_off
 
   offset = offset % align;
   return ((offset + size + align - 1) / align
-         > ((unsigned HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
-            / align));
+         > tree_to_uhwi (TYPE_SIZE (type)) / align);
 }
 #endif
 
Index: gcc/tree-object-size.c
===================================================================
--- gcc/tree-object-size.c      2013-11-16 09:59:37.038618983 +0000
+++ gcc/tree-object-size.c      2013-11-16 10:14:40.484264392 +0000
@@ -210,15 +210,13 @@ addr_object_size (struct object_size_inf
   else if (pt_var
           && DECL_P (pt_var)
           && tree_fits_uhwi_p (DECL_SIZE_UNIT (pt_var))
-          && (unsigned HOST_WIDE_INT)
-               tree_to_uhwi (DECL_SIZE_UNIT (pt_var)) < offset_limit)
+          && tree_to_uhwi (DECL_SIZE_UNIT (pt_var)) < offset_limit)
     pt_var_size = DECL_SIZE_UNIT (pt_var);
   else if (pt_var
           && TREE_CODE (pt_var) == STRING_CST
           && TYPE_SIZE_UNIT (TREE_TYPE (pt_var))
           && tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)))
-          && (unsigned HOST_WIDE_INT)
-             tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)))
+          && tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)))
              < offset_limit)
     pt_var_size = TYPE_SIZE_UNIT (TREE_TYPE (pt_var));
   else
Index: gcc/tree-sra.c
===================================================================
--- gcc/tree-sra.c      2013-11-16 09:59:37.055619122 +0000
+++ gcc/tree-sra.c      2013-11-16 10:14:40.484264392 +0000
@@ -2488,7 +2488,7 @@ analyze_all_variable_accesses (void)
        if (TREE_CODE (var) == VAR_DECL
            && type_consists_of_records_p (TREE_TYPE (var)))
          {
-           if ((unsigned) tree_to_uhwi (TYPE_SIZE (TREE_TYPE (var)))
+           if (tree_to_uhwi (TYPE_SIZE (TREE_TYPE (var)))
                <= max_total_scalarization_size)
              {
                completely_scalarize_var (var);
Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c     2013-11-16 09:59:37.082619342 +0000
+++ gcc/tree-ssa-forwprop.c     2013-11-16 10:14:40.485264402 +0000
@@ -1601,7 +1601,7 @@ simplify_builtin_call (gimple_stmt_itera
             as the new memcpy length, if it is too big, bail out.  */
          src_len = tree_to_uhwi (diff);
          src_len += tree_to_uhwi (len2);
-         if (src_len < (unsigned HOST_WIDE_INT) tree_to_uhwi (len1))
+         if (src_len < tree_to_uhwi (len1))
            src_len = tree_to_uhwi (len1);
          if (src_len > 1024)
            break;
@@ -2319,7 +2319,7 @@ simplify_rotate (gimple_stmt_iterator *g
   /* CNT1 + CNT2 == B case above.  */
   if (tree_fits_uhwi_p (def_arg2[0])
       && tree_fits_uhwi_p (def_arg2[1])
-      && (unsigned HOST_WIDE_INT) tree_to_uhwi (def_arg2[0])
+      && tree_to_uhwi (def_arg2[0])
         + tree_to_uhwi (def_arg2[1]) == TYPE_PRECISION (rtype))
     rotcnt = def_arg2[0];
   else if (TREE_CODE (def_arg2[0]) != SSA_NAME
Index: gcc/tree-ssa-strlen.c
===================================================================
--- gcc/tree-ssa-strlen.c       2013-11-16 09:59:37.129619727 +0000
+++ gcc/tree-ssa-strlen.c       2013-11-16 10:14:40.485264402 +0000
@@ -850,12 +850,11 @@ adjust_last_stmt (strinfo si, gimple stm
     {
       if (!tree_fits_uhwi_p (last.len)
          || integer_zerop (len)
-         || (unsigned HOST_WIDE_INT) tree_to_uhwi (len)
-            != (unsigned HOST_WIDE_INT) tree_to_uhwi (last.len) + 1)
+         || tree_to_uhwi (len) != tree_to_uhwi (last.len) + 1)
        return;
       /* Don't adjust the length if it is divisible by 4, it is more efficient
         to store the extra '\0' in that case.  */
-      if ((((unsigned HOST_WIDE_INT) tree_to_uhwi (len)) & 3) == 0)
+      if ((tree_to_uhwi (len) & 3) == 0)
        return;
     }
   else if (TREE_CODE (len) == SSA_NAME)
@@ -1337,8 +1336,7 @@ handle_builtin_memcpy (enum built_in_fun
       /* Handle memcpy (x, "abcd", 5) or
         memcpy (x, "abc\0uvw", 7).  */
       if (!tree_fits_uhwi_p (len)
-         || (unsigned HOST_WIDE_INT) tree_to_uhwi (len)
-            <= (unsigned HOST_WIDE_INT) ~idx)
+         || tree_to_uhwi (len) <= (unsigned HOST_WIDE_INT) ~idx)
        return;
     }
 
@@ -1627,8 +1625,7 @@ handle_pointer_plus (gimple_stmt_iterato
     {
       tree off = gimple_assign_rhs2 (stmt);
       if (tree_fits_uhwi_p (off)
-         && (unsigned HOST_WIDE_INT) tree_to_uhwi (off)
-            <= (unsigned HOST_WIDE_INT) ~idx)
+         && tree_to_uhwi (off) <= (unsigned HOST_WIDE_INT) ~idx)
        ssa_ver_to_stridx[SSA_NAME_VERSION (lhs)]
            = ~(~idx - (int) tree_to_uhwi (off));
       return;
Index: gcc/tree-switch-conversion.c
===================================================================
--- gcc/tree-switch-conversion.c        2013-11-16 10:13:53.897801435 +0000
+++ gcc/tree-switch-conversion.c        2013-11-16 10:14:40.486264412 +0000
@@ -701,7 +701,7 @@ check_range (struct switch_conv_info *in
       return false;
     }
 
-  if ((unsigned HOST_WIDE_INT) tree_to_uhwi (info->range_size)
+  if (tree_to_uhwi (info->range_size)
       > ((unsigned) info->count * SWITCH_CONVERSION_BRANCH_RATIO))
     {
       info->reason = "the maximum range-branch ratio exceeded";
Index: gcc/tree-vect-patterns.c
===================================================================
--- gcc/tree-vect-patterns.c    2013-11-16 09:59:37.170620062 +0000
+++ gcc/tree-vect-patterns.c    2013-11-16 10:14:40.486264412 +0000
@@ -1636,8 +1636,7 @@ vect_recog_rotate_pattern (vec<gimple> *
   if (TREE_CODE (def) == INTEGER_CST)
     {
       if (!tree_fits_uhwi_p (def)
-         || (unsigned HOST_WIDE_INT) tree_to_uhwi (def)
-            >= GET_MODE_PRECISION (TYPE_MODE (type))
+         || tree_to_uhwi (def) >= GET_MODE_PRECISION (TYPE_MODE (type))
          || integer_zerop (def))
        return NULL;
       def2 = build_int_cst (stype,
Index: gcc/tsan.c
===================================================================
--- gcc/tsan.c  2013-11-16 09:59:37.212620405 +0000
+++ gcc/tsan.c  2013-11-16 10:14:40.489264441 +0000
@@ -448,8 +448,7 @@ instrument_builtin_call (gimple_stmt_ite
          case fetch_op:
            last_arg = gimple_call_arg (stmt, num - 1);
            if (!tree_fits_uhwi_p (last_arg)
-               || (unsigned HOST_WIDE_INT) tree_to_uhwi (last_arg)
-                  > MEMMODEL_SEQ_CST)
+               || tree_to_uhwi (last_arg) > MEMMODEL_SEQ_CST)
              return;
            gimple_call_set_fndecl (stmt, decl);
            update_stmt (stmt);
@@ -520,12 +519,10 @@ instrument_builtin_call (gimple_stmt_ite
            for (j = 0; j < 6; j++)
              args[j] = gimple_call_arg (stmt, j);
            if (!tree_fits_uhwi_p (args[4])
-               || (unsigned HOST_WIDE_INT) tree_to_uhwi (args[4])
-                  > MEMMODEL_SEQ_CST)
+               || tree_to_uhwi (args[4]) > MEMMODEL_SEQ_CST)
              return;
            if (!tree_fits_uhwi_p (args[5])
-               || (unsigned HOST_WIDE_INT) tree_to_uhwi (args[5])
-                  > MEMMODEL_SEQ_CST)
+               || tree_to_uhwi (args[5]) > MEMMODEL_SEQ_CST)
              return;
            update_gimple_call (gsi, decl, 5, args[0], args[1], args[2],
                                args[4], args[5]);
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c     2013-11-16 09:59:36.390613688 +0000
+++ gcc/cfgexpand.c     2013-11-16 10:14:40.374263307 +0000
@@ -1133,7 +1133,7 @@ defer_stack_allocation (tree var, bool t
   /* Whether the variable is small enough for immediate allocation not to be
      a problem with regard to the frame size.  */
   bool smallish
-    = (tree_to_uhwi (DECL_SIZE_UNIT (var))
+    = ((HOST_WIDE_INT) tree_to_uhwi (DECL_SIZE_UNIT (var))
        < PARAM_VALUE (PARAM_MIN_SIZE_FOR_STACK_SHARING));
 
   /* If stack protection is enabled, *all* stack variables must be deferred,
Index: gcc/trans-mem.c
===================================================================
--- gcc/trans-mem.c     2013-11-16 09:59:37.027618893 +0000
+++ gcc/trans-mem.c     2013-11-16 10:14:40.484264392 +0000
@@ -1104,7 +1104,7 @@ tm_log_add (basic_block entry_block, tre
          && transaction_invariant_address_p (lp->addr, entry_block)
          && TYPE_SIZE_UNIT (type) != NULL
          && tree_fits_uhwi_p (TYPE_SIZE_UNIT (type))
-         && (tree_to_uhwi (TYPE_SIZE_UNIT (type))
+         && ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE_UNIT (type))
              < PARAM_VALUE (PARAM_TM_MAX_AGGREGATE_SIZE))
          /* We must be able to copy this type normally.  I.e., no
             special constructors and the like.  */
Index: gcc/config/aarch64/aarch64.c
===================================================================
--- gcc/config/aarch64/aarch64.c        2013-11-16 09:59:36.442614113 +0000
+++ gcc/config/aarch64/aarch64.c        2013-11-16 10:14:40.398263544 +0000
@@ -6041,7 +6041,7 @@ aapcs_vfp_sub_candidate (const_tree type
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
@@ -6071,7 +6071,7 @@ aapcs_vfp_sub_candidate (const_tree type
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
@@ -6103,7 +6103,7 @@ aapcs_vfp_sub_candidate (const_tree type
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c        2013-11-16 09:59:36.512614685 +0000
+++ gcc/config/arm/arm.c        2013-11-16 10:25:01.702983041 +0000
@@ -4723,7 +4723,7 @@ aapcs_vfp_sub_candidate (const_tree type
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
@@ -4753,7 +4753,7 @@ aapcs_vfp_sub_candidate (const_tree type
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
@@ -4785,7 +4785,7 @@ aapcs_vfp_sub_candidate (const_tree type
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c  2013-11-16 09:59:36.747616605 +0000
+++ gcc/config/rs6000/rs6000.c  2013-11-16 10:14:40.477264323 +0000
@@ -8560,7 +8560,7 @@ rs6000_aggregate_candidate (const_tree t
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
@@ -8590,7 +8590,7 @@ rs6000_aggregate_candidate (const_tree t
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
@@ -8622,7 +8622,7 @@ rs6000_aggregate_candidate (const_tree t
 
        /* There must be no padding.  */
        if (!tree_fits_uhwi_p (TYPE_SIZE (type))
-           || (tree_to_uhwi (TYPE_SIZE (type))
+           || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
                != count * GET_MODE_BITSIZE (*modep)))
          return -1;
 
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c      2013-11-16 09:59:36.672615992 +0000
+++ gcc/config/mips/mips.c      2013-11-16 10:14:40.463264185 +0000
@@ -14927,7 +14927,7 @@ r10k_safe_address_p (rtx x, rtx insn)
    a link-time-constant address.  */
 
 static bool
-r10k_safe_mem_expr_p (tree expr, HOST_WIDE_INT offset)
+r10k_safe_mem_expr_p (tree expr, unsigned HOST_WIDE_INT offset)
 {
   HOST_WIDE_INT bitoffset, bitsize;
   tree inner, var_offset;
@@ -14940,7 +14940,7 @@ r10k_safe_mem_expr_p (tree expr, HOST_WI
     return false;
 
   offset += bitoffset / BITS_PER_UNIT;
-  return offset >= 0 && offset < tree_to_uhwi (DECL_SIZE_UNIT (inner));
+  return offset < tree_to_uhwi (DECL_SIZE_UNIT (inner));
 }
 
 /* A for_each_rtx callback for which DATA points to the instruction

Reply via email to