diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2016-05-02 09:40:09 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2016-05-02 09:40:09 +0000 |
commit | 697e0b28cca9e5f3e1ee59131c048ef93014fb2f (patch) | |
tree | 8813b12d24cde53b2b940740605d9108aa099d28 /gcc/fold-const.c | |
parent | 8de73453a42758af02bb23ed58f4b1e78ad11bc7 (diff) | |
download | gcc-697e0b28cca9e5f3e1ee59131c048ef93014fb2f.zip gcc-697e0b28cca9e5f3e1ee59131c048ef93014fb2f.tar.gz gcc-697e0b28cca9e5f3e1ee59131c048ef93014fb2f.tar.bz2 |
Add a wi::to_wide helper function
As Richard says, we ought to have a convenient way of converting
an INTEGER_CST to a wide_int of a particular precision without
having to extract the sign of the INTEGER_CST's type each time.
This patch adds a wi::to_wide helper for that, alongside the
existing wi::to_offset and wi::to_widest.
Tested on x86_64-linux-gnu and aarch64-linux-gnu.
gcc/
* 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.
gcc/c-family/
* c-common.c (shorten_compare): Use wi::to_wide.
From-SVN: r235721
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8ece0f8..3c389ee 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -963,8 +963,7 @@ int_const_binop_1 (enum tree_code code, const_tree arg1, const_tree parg2, 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) { @@ -6397,10 +6396,8 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, 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 |