Merge from trunk.
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Nov 2013 16:00:55 +0000 (16:00 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 18 Nov 2013 16:00:55 +0000 (16:00 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@204969 138bc75d-0d04-0410-961f-82ee72b054a4

41 files changed:
1  2 
gcc/ada/gcc-interface/cuintp.c
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/trans.c
gcc/builtins.c
gcc/c-family/c-common.c
gcc/c/c-decl.c
gcc/cgraph.c
gcc/cgraphunit.c
gcc/config/arc/arc.c
gcc/config/arm/arm.c
gcc/config/i386/i386.c
gcc/config/rs6000/rs6000.c
gcc/cp/decl.c
gcc/dwarf2out.c
gcc/expr.c
gcc/fold-const.c
gcc/fortran/trans-intrinsic.c
gcc/gimple.c
gcc/godump.c
gcc/ipa-devirt.c
gcc/ipa-prop.c
gcc/lto/lto.c
gcc/omp-low.c
gcc/predict.c
gcc/rtl.h
gcc/stor-layout.c
gcc/tree-affine.c
gcc/tree-inline.c
gcc/tree-object-size.c
gcc/tree-sra.c
gcc/tree-ssa-alias.c
gcc/tree-ssa-forwprop.c
gcc/tree-ssa-loop-im.c
gcc/tree-ssa-structalias.c
gcc/tree-ssa.c
gcc/tree-switch-conversion.c
gcc/tree-vect-generic.c
gcc/tree-vect-patterns.c
gcc/tree.c
gcc/tree.h
gcc/value-prof.c

Simple merge
Simple merge
Simple merge
diff --cc gcc/builtins.c
@@@ -3101,6 -3095,51 +3101,51 @@@ builtin_memcpy_read_str (void *data, HO
    return c_readstr (str + offset, mode);
  }
  
 -      double_int min, max;
+ /* LEN specify length of the block of memcpy/memset operation.
+    Figure out its range and put it into MIN_SIZE/MAX_SIZE.  */
+ static void
+ determine_block_size (tree len, rtx len_rtx,
+                     unsigned HOST_WIDE_INT *min_size,
+                     unsigned HOST_WIDE_INT *max_size)
+ {
+   if (CONST_INT_P (len_rtx))
+     {
+       *min_size = *max_size = UINTVAL (len_rtx);
+       return;
+     }
+   else
+     {
 -        if (min.fits_uhwi ())
++      widest_int min, max;
+       if (TREE_CODE (len) == SSA_NAME 
+         && get_range_info (len, &min, &max) == VR_RANGE)
+       {
 -        if (max.fits_uhwi ())
++        if (wi::fits_uhwi_p (min))
+           *min_size = min.to_uhwi ();
+         else
+           *min_size = 0;
++        if (wi::fits_uhwi_p (max))
+           *max_size = max.to_uhwi ();
+         else
+           *max_size = (HOST_WIDE_INT)-1;
+       }
+       else
+       {
+         if (tree_fits_uhwi_p (TYPE_MIN_VALUE (TREE_TYPE (len))))
+           *min_size = tree_to_uhwi (TYPE_MIN_VALUE (TREE_TYPE (len)));
+         else
+           *min_size = 0;
+         if (tree_fits_uhwi_p (TYPE_MAX_VALUE (TREE_TYPE (len))))
+           *max_size = tree_to_uhwi (TYPE_MAX_VALUE (TREE_TYPE (len)));
+         else
+           *max_size = GET_MODE_MASK (GET_MODE (len_rtx));
+       }
+     }
+   gcc_checking_assert (*max_size <=
+                      (unsigned HOST_WIDE_INT)
+                         GET_MODE_MASK (GET_MODE (len_rtx)));
+ }
  /* Expand a call EXP to the memcpy builtin.
     Return NULL_RTX if we failed, the caller should emit a normal call,
     otherwise try to get the result in TARGET, if convenient (and in
Simple merge
diff --cc gcc/c/c-decl.c
Simple merge
diff --cc gcc/cgraph.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -8552,13 -8559,13 +8556,11 @@@ rs6000_aggregate_candidate (const_tree 
            || count < 0)
          return -1;
  
-       count *= (1 + tree_low_cst (TYPE_MAX_VALUE (index), 1)
-                     - tree_low_cst (TYPE_MIN_VALUE (index), 1));
+       count *= (1 + tree_to_uhwi (TYPE_MAX_VALUE (index))
+                     - tree_to_uhwi (TYPE_MIN_VALUE (index)));
  
        /* There must be no padding.  */
-       if (!host_integerp (TYPE_SIZE (type), 1)
-           || (tree_low_cst (TYPE_SIZE (type), 1)
 -      if (!tree_fits_uhwi_p (TYPE_SIZE (type))
 -          || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
--              != count * GET_MODE_BITSIZE (*modep)))
++      if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep)))
          return -1;
  
        return count;
          }
  
        /* There must be no padding.  */
-       if (!host_integerp (TYPE_SIZE (type), 1)
-           || (tree_low_cst (TYPE_SIZE (type), 1)
 -      if (!tree_fits_uhwi_p (TYPE_SIZE (type))
 -          || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
--              != count * GET_MODE_BITSIZE (*modep)))
++      if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep)))
          return -1;
  
        return count;
          }
  
        /* There must be no padding.  */
-       if (!host_integerp (TYPE_SIZE (type), 1)
-           || (tree_low_cst (TYPE_SIZE (type), 1)
 -      if (!tree_fits_uhwi_p (TYPE_SIZE (type))
 -          || ((HOST_WIDE_INT) tree_to_uhwi (TYPE_SIZE (type))
--              != count * GET_MODE_BITSIZE (*modep)))
++      if (wi::ne_p (TYPE_SIZE (type), count * GET_MODE_BITSIZE (*modep)))
          return -1;
  
        return count;
diff --cc gcc/cp/decl.c
Simple merge
diff --cc gcc/dwarf2out.c
Simple merge
diff --cc gcc/expr.c
Simple merge
Simple merge
@@@ -39,7 -39,7 +39,8 @@@ along with GCC; see the file COPYING3
  #include "trans-array.h"
  /* Only for gfc_trans_assign and gfc_trans_pointer_assign.  */
  #include "trans-stmt.h"
+ #include "tree-nested.h"
 +#include "wide-int.h"
  
  /* This maps Fortran intrinsic math functions to external library or GCC
     builtin functions.  */
diff --cc gcc/gimple.c
Simple merge
diff --cc gcc/godump.c
@@@ -987,10 -986,12 +987,9 @@@ go_output_typedef (struct godump_contai
                     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)
 -                    TREE_INT_CST_HIGH (TREE_VALUE (element))),
 -                   TREE_INT_CST_LOW (TREE_VALUE (element)));
 +          print_hex (element, buf);
  
          mhval->value = xstrdup (buf);
          *slot = mhval;
Simple merge
diff --cc gcc/ipa-prop.c
Simple merge
diff --cc gcc/lto/lto.c
Simple merge
diff --cc gcc/omp-low.c
Simple merge
diff --cc gcc/predict.c
Simple merge
diff --cc gcc/rtl.h
Simple merge
Simple merge
@@@ -28,7 -28,7 +28,8 @@@ along with GCC; see the file COPYING3
  #include "gimplify.h"
  #include "flags.h"
  #include "dumpfile.h"
+ #include "cfgexpand.h"
 +#include "wide-int-print.h"
  
  /* Extends CST as appropriate for the affine combinations COMB.  */
  
Simple merge
Simple merge
diff --cc gcc/tree-sra.c
Simple merge
@@@ -615,8 -615,9 +615,9 @@@ ao_ref_init_from_ptr_and_size (ao_ref *
    ref->offset += extra_offset;
    if (size
        && tree_fits_shwi_p (size)
-       && tree_to_shwi (size) * BITS_PER_UNIT / BITS_PER_UNIT == tree_to_shwi (size))
 -      && TREE_INT_CST_LOW (size) * BITS_PER_UNIT / BITS_PER_UNIT
 -       == TREE_INT_CST_LOW (size))
 -    ref->max_size = ref->size = TREE_INT_CST_LOW (size) * BITS_PER_UNIT;
++      && tree_to_shwi (size) * BITS_PER_UNIT / BITS_PER_UNIT
++       == tree_to_hwi (size))
 +    ref->max_size = ref->size = tree_to_shwi (size) * BITS_PER_UNIT;
    else
      ref->max_size = ref->size = -1;
    ref->ref_alias_set = 0;
Simple merge
Simple merge
Simple merge
diff --cc gcc/tree-ssa.c
Simple merge
Simple merge
@@@ -50,10 -50,10 +50,11 @@@ static tre
  build_replicated_const (tree type, tree inner_type, HOST_WIDE_INT value)
  {
    int width = tree_to_uhwi (TYPE_SIZE (inner_type));
 -  int n = HOST_BITS_PER_WIDE_INT / width;
 -  unsigned HOST_WIDE_INT low, high, mask;
 -  tree ret;
 +  int n = TYPE_PRECISION (type) / width;
 +  unsigned HOST_WIDE_INT low, mask;
 +  HOST_WIDE_INT a[WIDE_INT_MAX_ELTS];
 +  int i;
    gcc_assert (n);
  
    if (width == HOST_BITS_PER_WIDE_INT)
Simple merge
diff --cc gcc/tree.c
@@@ -6956,9 -6960,62 +6954,53 @@@ tree_int_cst_lt (const_tree t1, const_t
  int
  tree_int_cst_compare (const_tree t1, const_tree t2)
  {
 -  if (tree_int_cst_lt (t1, t2))
 -    return -1;
 -  else if (tree_int_cst_lt (t2, t1))
 -    return 1;
 -  else
 -    return 0;
 +  return wi::cmps (wi::to_widest (t1), wi::to_widest (t2));
  }
  
 -        && ((TREE_INT_CST_HIGH (t) == 0
 -             && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) >= 0)
 -            || (TREE_INT_CST_HIGH (t) == -1
 -                && (HOST_WIDE_INT) TREE_INT_CST_LOW (t) < 0
 -                && !TYPE_UNSIGNED (TREE_TYPE (t)))));
+ /* Return true if T is an INTEGER_CST whose numerical value (extended
+    according to TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  */
+ bool
+ tree_fits_shwi_p (const_tree t)
+ {
+   return (t != NULL_TREE
+         && TREE_CODE (t) == INTEGER_CST
 -        && TREE_INT_CST_HIGH (t) == 0);
++        && wi::fits_shwi_p (wi::to_widest (t)));
+ }
+ /* Return true if T is an INTEGER_CST whose numerical value (extended
+    according to TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  */
+ bool
+ tree_fits_uhwi_p (const_tree t)
+ {
+   return (t != NULL_TREE
+         && TREE_CODE (t) == INTEGER_CST
 -  return TREE_INT_CST_LOW (t);
++        && wi::fits_uhwi_p (wi::to_widest (t)));
+ }
+ /* T is an INTEGER_CST whose numerical value (extended according to
+    TYPE_UNSIGNED) fits in a signed HOST_WIDE_INT.  Return that
+    HOST_WIDE_INT.  */
+ HOST_WIDE_INT
+ tree_to_shwi (const_tree t)
+ {
+   gcc_assert (tree_fits_shwi_p (t));
 -  return TREE_INT_CST_LOW (t);
++  return TREE_INT_CST_ELT (t, 0);
+ }
+ /* T is an INTEGER_CST whose numerical value (extended according to
+    TYPE_UNSIGNED) fits in an unsigned HOST_WIDE_INT.  Return that
+    HOST_WIDE_INT.  */
+ unsigned HOST_WIDE_INT
+ tree_to_uhwi (const_tree t)
+ {
+   gcc_assert (tree_fits_uhwi_p (t));
++  return TREE_INT_CST_ELT (t, 0);
+ }
  /* Return the most significant (sign) bit of T.  */
  
  int
diff --cc gcc/tree.h
@@@ -3143,174 -3120,6 +3146,44 @@@ omp_clause_elt_check (const_tree __t, i
  
  #endif
  
- /* Return true if T is an INTEGER_CST whose value must be non-negative
-    and can be represented in a single unsigned HOST_WIDE_INT.  This
-    function differs from the cst_fits versions in that the signedness
-    of the type of cst is considered.  */
- static inline bool
- tree_fits_uhwi_p (const_tree cst)
- {
-   tree type;
-   if (cst == NULL_TREE)
-     return false;
-   type = TREE_TYPE (cst);
-   if (TREE_CODE (cst) != INTEGER_CST)
-     return false;
-   if (TREE_INT_CST_NUNITS (cst) == 1)
-     {
-       if ((TYPE_SIGN (type) == UNSIGNED)
-         && (TYPE_PRECISION (type) <= HOST_BITS_PER_WIDE_INT))
-       return true;
-       /* For numbers of unsigned type that are longer than a HWI, if
-        the top bit of the bottom word is set, and there is not
-        another element, then this is too large to fit in a single
-        hwi.  For signed numbers, negative values are not allowed. */
-       if (TREE_INT_CST_ELT (cst, 0) >= 0)
-       return true;
-     }
-   else if (TREE_INT_CST_NUNITS (cst) == 2)
-     {
-       if (TREE_INT_CST_ELT (cst, 1) == 0)
-       return true;
-     }
-   return false;
- }
- /* Return true if CST is an INTEGER_CST whose value can be represented
-    in a single HOST_WIDE_INT.  This function differs from the cst_fits
-    versions in that the signedness of the type of cst is
-    considered.  */
- static inline bool
- tree_fits_shwi_p (const_tree cst)
- {
-   if (cst == NULL_TREE)
-     return false;
-   if (TREE_CODE (cst) != INTEGER_CST)
-     return false;
-   if (TREE_INT_CST_NUNITS (cst) != 1)
-     return false;
-   if (TYPE_SIGN (TREE_TYPE (cst)) == SIGNED)
-     return true;
-   if (TREE_INT_CST_ELT (cst, 0) >= 0)
-     return true;
-   return false;
- }
- /* Return true if T is an INTEGER_CST that can be manipulated
-    efficiently on the host.  If SIGN is SIGNED, the value can be
-    represented in a single HOST_WIDE_INT.  If SIGN is UNSIGNED, the
-    value must be non-negative and can be represented in a single
-    unsigned HOST_WIDE_INT.  */
- static inline bool
- tree_fits_hwi_p (const_tree cst, signop sign)
- {
-   return sign ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst);
- }
- /* Return true if T is an INTEGER_CST that can be manipulated
-    efficiently on the host.  If the sign of CST is SIGNED, the value
-    can be represented in a single HOST_WIDE_INT.  If the sign of CST
-    is UNSIGNED, the value must be non-negative and can be represented
-    in a single unsigned HOST_WIDE_INT.  */
- static inline bool
- tree_fits_hwi_p (const_tree cst)
- {
-   if (cst == NULL_TREE)
-     return false;
-   if (TREE_CODE (cst) != INTEGER_CST)
-     return false;
-   return TYPE_UNSIGNED (TREE_TYPE (cst)) 
-     ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst);
- }
- /* Return the unsigned HOST_WIDE_INT least significant bits of CST.
-    If checking is enabled, this ices if the value does not fit.  */
- static inline unsigned HOST_WIDE_INT
- tree_to_uhwi (const_tree cst)
- {
-   gcc_checking_assert (tree_fits_uhwi_p (cst));
-   return (unsigned HOST_WIDE_INT)TREE_INT_CST_ELT (cst, 0);
- }
- /* Return the HOST_WIDE_INT least significant bits of CST.  If
-    checking is enabled, this ices if the value does not fit.  */
- static inline HOST_WIDE_INT
- tree_to_shwi (const_tree cst)
- {
-   gcc_checking_assert (tree_fits_shwi_p (cst));
-   return (HOST_WIDE_INT)TREE_INT_CST_ELT (cst, 0);
- }
 +/* Checks that X is an integer constant that can be expressed in a signed
 +   HOST_WIDE_INT without loss of precision.  This function differs from
 +   the tree_fits_* versions in that the signedness of the type of X is
 +   not considered.  */
 +
 +static inline bool
 +cst_fits_shwi_p (const_tree x)
 +{
 +  if (TREE_CODE (x) != INTEGER_CST)
 +    return false;
 +
 +  return TREE_INT_CST_NUNITS (x) == 1;
 +}
 +
 +/* Checks that X is an integer constant that can be expressed in an unsigned
 +   HOST_WIDE_INT without loss of precision.  This function differs from
 +   the tree_fits_* versions in that the signedness of the type of X is
 +   not considered.  */
 +
 +static inline bool
 +cst_fits_uhwi_p (const_tree x)
 +{
 +  if (TREE_CODE (x) != INTEGER_CST)
 +    return false;
 +
 +  return TREE_INT_CST_NUNITS (x) == 1 && TREE_INT_CST_ELT (x, 0) >= 0;
 +}
 +
- /* Return the HOST_WIDE_INT least significant bits of CST.  The sign
-    of the checking is based on SIGNOP. */
- static inline HOST_WIDE_INT
- tree_to_hwi (const_tree cst, signop sgn)
- {
-   if (sgn == SIGNED)
-     return tree_to_shwi (cst);
-   else
-     return tree_to_uhwi (cst);
- }
 +/* Return the HOST_WIDE_INT least significant bits of CST.  No
 +   checking is done to assure that it fits.  It is assumed that one of
 +   tree_fits_uhwi_p or tree_fits_shwi_p was done before this call. */
 +
 +static inline HOST_WIDE_INT
 +tree_to_hwi (const_tree cst)
 +{
 +  return TREE_INT_CST_ELT (cst, 0);
 +}
 +
  /* Compute the number of operands in an expression node NODE.  For
     tcc_vl_exp nodes like CALL_EXPRs, this is stored in the node itself,
     otherwise it is looked up from the node's code.  */
@@@ -3843,9 -3657,36 +3716,36 @@@ extern int attribute_list_contained (co
  extern int tree_int_cst_equal (const_tree, const_tree);
  extern int tree_int_cst_lt (const_tree, const_tree);
  extern int tree_int_cst_compare (const_tree, const_tree);
 -  return TREE_INT_CST_LOW (t);
+ extern bool tree_fits_shwi_p (const_tree)
+ #ifndef ENABLE_TREE_CHECKING
+   ATTRIBUTE_PURE /* tree_fits_shwi_p is pure only when checking is disabled.  */
+ #endif
+   ;
+ extern bool tree_fits_uhwi_p (const_tree)
+ #ifndef ENABLE_TREE_CHECKING
+   ATTRIBUTE_PURE /* tree_fits_uhwi_p is pure only when checking is disabled.  */
+ #endif
+   ;
+ extern HOST_WIDE_INT tree_to_shwi (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)
+ {
+   gcc_assert (tree_fits_shwi_p (t));
 -  return TREE_INT_CST_LOW (t);
++  return TREE_INT_CST_ELT (t, 0);
+ }
+ extern inline __attribute__ ((__gnu_inline__)) unsigned HOST_WIDE_INT
+ tree_to_uhwi (const_tree t)
+ {
+   gcc_assert (tree_fits_uhwi_p (t));
++  return TREE_INT_CST_ELT (t, 0);
+ }
+ #endif
  extern int tree_int_cst_sgn (const_tree);
  extern int tree_int_cst_sign_bit (const_tree);
 -extern unsigned int tree_int_cst_min_precision (tree, bool);
 +extern unsigned int tree_int_cst_min_precision (tree, signop);
  extern bool tree_expr_nonnegative_p (tree);
  extern bool tree_expr_nonnegative_warnv_p (tree, bool *);
  extern bool may_negate_without_overflow_p (const_tree);
@@@ -3854,6 -3695,6 +3754,50 @@@ extern tree excess_precision_type (tree
  extern bool valid_constant_size_p (const_tree);
  extern unsigned int element_precision (const_tree);
  
++/* Return true if T is an INTEGER_CST that can be manipulated
++   efficiently on the host.  If SIGN is SIGNED, the value can be
++   represented in a single HOST_WIDE_INT.  If SIGN is UNSIGNED, the
++   value must be non-negative and can be represented in a single
++   unsigned HOST_WIDE_INT.  */
++
++static inline bool
++tree_fits_hwi_p (const_tree cst, signop sign)
++{
++  return sign ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst);
++}
++
++/* Return true if T is an INTEGER_CST that can be manipulated
++   efficiently on the host.  If the sign of CST is SIGNED, the value
++   can be represented in a single HOST_WIDE_INT.  If the sign of CST
++   is UNSIGNED, the value must be non-negative and can be represented
++   in a single unsigned HOST_WIDE_INT.  */
++
++static inline bool
++tree_fits_hwi_p (const_tree cst)
++{
++  if (cst == NULL_TREE)
++    return false;
++
++  if (TREE_CODE (cst) != INTEGER_CST)
++    return false;
++
++  return TYPE_UNSIGNED (TREE_TYPE (cst)) 
++    ? tree_fits_uhwi_p (cst) : tree_fits_shwi_p (cst);
++}
++
++/* Return the HOST_WIDE_INT least significant bits of CST.  The sign
++   of the checking is based on SIGNOP. */
++
++static inline HOST_WIDE_INT
++tree_to_hwi (const_tree cst, signop sgn)
++{
++  if (sgn == SIGNED)
++    return tree_to_shwi (cst);
++  else
++    return tree_to_uhwi (cst);
++}
++
++
  /* Construct various nodes representing fract or accum data types.  */
  
  extern tree make_fract_type (int, int, int);
Simple merge