diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-10-09 10:51:45 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-10-09 10:51:45 +0000 |
commit | 7b27cb4b510c4c0ae8446140929380aba4a9f79a (patch) | |
tree | f4ff87714e14c46a92572a3688e8ec637e80ea78 /gcc/tree-ssa-ccp.c | |
parent | 191411e43abdefb0c999215bf081d4a5776f281a (diff) |
Allow non-wi <op> wi
This patch uses global rather than member operators for wide-int.h,
so that the first operand can be a non-wide-int type.
The patch also removes the and_not and or_not member functions.
It was already inconsistent to have member functions for these
two operations (one of which was never used) and not other wi::
ones like udiv. After the operator change, we'd have the additional
inconsistency that "non-wi & wi" would work but "non-wi.and_not (wi)"
wouldn't.
2017-10-09 Richard Sandiford <richard.sandiford@linaro.org>
gcc/
* wide-int.h (WI_BINARY_OPERATOR_RESULT): New macro.
(WI_BINARY_PREDICATE_RESULT): Likewise.
(wi::binary_traits::operator_result): New type.
(wi::binary_traits::predicate_result): Likewise.
(generic_wide_int::operator~, unary generic_wide_int::operator-)
(generic_wide_int::operator==, generic_wide_int::operator!=)
(generic_wide_int::operator&, generic_wide_int::and_not)
(generic_wide_int::operator|, generic_wide_int::or_not)
(generic_wide_int::operator^, generic_wide_int::operator+
(binary generic_wide_int::operator-, generic_wide_int::operator*):
Delete.
(operator~, unary operator-, operator==, operator!=, operator&)
(operator|, operator^, operator+, binary operator-, operator*): New
functions.
* expr.c (get_inner_reference): Use wi::bit_and_not.
* fold-const.c (fold_binary_loc): Likewise.
* ipa-prop.c (ipa_compute_jump_functions_for_edge): Likewise.
* tree-ssa-ccp.c (get_value_from_alignment): Likewise.
(bit_value_binop): Likewise.
* tree-ssa-math-opts.c (find_bswap_or_nop_load): Likewise.
* tree-vrp.c (zero_nonzero_bits_from_vr): Likewise.
(extract_range_from_binary_expr_1): Likewise.
(masked_increment): Likewise.
(simplify_bit_ops_using_ranges): Likewise.
From-SVN: r253539
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r-- | gcc/tree-ssa-ccp.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 9811640c2a5..df409af2d83 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -569,9 +569,11 @@ get_value_from_alignment (tree expr) gcc_assert (TREE_CODE (expr) == ADDR_EXPR); get_pointer_alignment_1 (expr, &align, &bitpos); - val.mask = (POINTER_TYPE_P (type) || TYPE_UNSIGNED (type) - ? wi::mask <widest_int> (TYPE_PRECISION (type), false) - : -1).and_not (align / BITS_PER_UNIT - 1); + val.mask = wi::bit_and_not + (POINTER_TYPE_P (type) || TYPE_UNSIGNED (type) + ? wi::mask <widest_int> (TYPE_PRECISION (type), false) + : -1, + align / BITS_PER_UNIT - 1); val.lattice_val = wi::sext (val.mask, TYPE_PRECISION (type)) == -1 ? VARYING : CONSTANT; if (val.lattice_val == CONSTANT) @@ -1308,8 +1310,9 @@ bit_value_binop (enum tree_code code, signop sgn, int width, case BIT_IOR_EXPR: /* The mask is constant where there is a known set bit, (m1 | m2) & ~((v1 & ~m1) | (v2 & ~m2)). */ - *mask = (r1mask | r2mask) - .and_not (r1val.and_not (r1mask) | r2val.and_not (r2mask)); + *mask = wi::bit_and_not (r1mask | r2mask, + wi::bit_and_not (r1val, r1mask) + | wi::bit_and_not (r2val, r2mask)); *val = r1val | r2val; break; @@ -1395,7 +1398,8 @@ bit_value_binop (enum tree_code code, signop sgn, int width, { /* Do the addition with unknown bits set to zero, to give carry-ins of zero wherever possible. */ - widest_int lo = r1val.and_not (r1mask) + r2val.and_not (r2mask); + widest_int lo = (wi::bit_and_not (r1val, r1mask) + + wi::bit_and_not (r2val, r2mask)); lo = wi::ext (lo, width, sgn); /* Do the addition with unknown bits set to one, to give carry-ins of one wherever possible. */ @@ -1447,7 +1451,7 @@ bit_value_binop (enum tree_code code, signop sgn, int width, case NE_EXPR: { widest_int m = r1mask | r2mask; - if (r1val.and_not (m) != r2val.and_not (m)) + if (wi::bit_and_not (r1val, m) != wi::bit_and_not (r2val, m)) { *mask = 0; *val = ((code == EQ_EXPR) ? 0 : 1); @@ -1486,8 +1490,10 @@ bit_value_binop (enum tree_code code, signop sgn, int width, /* If we know the most significant bits we know the values value ranges by means of treating varying bits as zero or one. Do a cross comparison of the max/min pairs. */ - maxmin = wi::cmp (o1val | o1mask, o2val.and_not (o2mask), sgn); - minmax = wi::cmp (o1val.and_not (o1mask), o2val | o2mask, sgn); + maxmin = wi::cmp (o1val | o1mask, + wi::bit_and_not (o2val, o2mask), sgn); + minmax = wi::cmp (wi::bit_and_not (o1val, o1mask), + o2val | o2mask, sgn); if (maxmin < 0) /* o1 is less than o2. */ { *mask = 0; |