+2016-05-02 Richard Sandiford <richard.sandiford@arm.com>
+
+ * tree.h (wi::to_wide): New function.
+ * expr.c (expand_expr_real_1): Use wi::to_wide.
+ * fold-const.c (int_const_binop_1): Likewise.
+ (extract_muldiv_1): Likewise.
+
2016-05-02 Richard Sandiford <richard.sandiford@arm.com>
* wide-int.h: Update offset_int and widest_int documentation.
+2016-05-02 Richard Sandiford <richard.sandiford@arm.com>
+
+ * c-common.c (shorten_compare): Use wi::to_wide.
+
2016-04-29 Cesar Philippidis <cesar@codesourcery.com>
PR middle-end/70626
/* Convert primop1 to target type, but do not introduce
additional overflow. We know primop1 is an int_cst. */
primop1 = force_fit_type (*restype_ptr,
- wide_int::from
- (primop1,
- TYPE_PRECISION (*restype_ptr),
- TYPE_SIGN (TREE_TYPE (primop1))),
+ wi::to_wide
+ (primop1,
+ TYPE_PRECISION (*restype_ptr)),
0, TREE_OVERFLOW (primop1));
}
if (type != *restype_ptr)
GET_MODE_PRECISION (TYPE_MODE (type)), we need to extend from
the former to the latter according to the signedness of the
type. */
- temp = immed_wide_int_const (wide_int::from
+ temp = immed_wide_int_const (wi::to_wide
(exp,
- GET_MODE_PRECISION (TYPE_MODE (type)),
- TYPE_SIGN (type)),
+ GET_MODE_PRECISION (TYPE_MODE (type))),
TYPE_MODE (type));
return temp;
signop sign = TYPE_SIGN (type);
bool overflow = false;
- wide_int arg2 = wide_int::from (parg2, TYPE_PRECISION (type),
- TYPE_SIGN (TREE_TYPE (parg2)));
+ wide_int arg2 = wi::to_wide (parg2, TYPE_PRECISION (type));
switch (code)
{
bool overflow_mul_p;
signop sign = TYPE_SIGN (ctype);
unsigned prec = TYPE_PRECISION (ctype);
- wide_int mul = wi::mul (wide_int::from (op1, prec,
- TYPE_SIGN (TREE_TYPE (op1))),
- wide_int::from (c, prec,
- TYPE_SIGN (TREE_TYPE (c))),
+ wide_int mul = wi::mul (wi::to_wide (op1, prec),
+ wi::to_wide (c, prec),
sign, &overflow_mul_p);
overflow_p = TREE_OVERFLOW (c) | TREE_OVERFLOW (op1);
if (overflow_mul_p
to_widest (const_tree);
generic_wide_int <extended_tree <ADDR_MAX_PRECISION> > to_offset (const_tree);
+
+ wide_int to_wide (const_tree, unsigned int);
}
inline unsigned int
return t;
}
+/* Convert INTEGER_CST T to a wide_int of precision PREC, extending or
+ truncating as necessary. When extending, use sign extension if T's
+ type is signed and zero extension if T's type is unsigned. */
+
+inline wide_int
+wi::to_wide (const_tree t, unsigned int prec)
+{
+ return wide_int::from (t, prec, TYPE_SIGN (TREE_TYPE (t)));
+}
+
template <int N>
inline wi::extended_tree <N>::extended_tree (const_tree t)
: m_t (t)