aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-10-09 10:51:45 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-10-09 10:51:45 +0000
commit7b27cb4b510c4c0ae8446140929380aba4a9f79a (patch)
treef4ff87714e14c46a92572a3688e8ec637e80ea78 /gcc/fold-const.c
parent191411e43abdefb0c999215bf081d4a5776f281a (diff)
downloadgcc-7b27cb4b510c4c0ae8446140929380aba4a9f79a.zip
gcc-7b27cb4b510c4c0ae8446140929380aba4a9f79a.tar.gz
gcc-7b27cb4b510c4c0ae8446140929380aba4a9f79a.tar.bz2
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/fold-const.c')
-rw-r--r--gcc/fold-const.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d8dc56c..aac62f8 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9888,7 +9888,7 @@ fold_binary_loc (location_t loc,
TYPE_PRECISION (TREE_TYPE (arg1)));
/* If (C1|C2) == ~0 then (X&C1)|C2 becomes X|C2. */
- if (msk.and_not (c1 | c2) == 0)
+ if (wi::bit_and_not (msk, c1 | c2) == 0)
{
tem = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0));
return fold_build2_loc (loc, BIT_IOR_EXPR, type, tem, arg1);
@@ -9899,12 +9899,13 @@ fold_binary_loc (location_t loc,
mode which allows further optimizations. */
c1 &= msk;
c2 &= msk;
- wide_int c3 = c1.and_not (c2);
+ wide_int c3 = wi::bit_and_not (c1, c2);
for (w = BITS_PER_UNIT; w <= width; w <<= 1)
{
wide_int mask = wi::mask (w, false,
TYPE_PRECISION (type));
- if (((c1 | c2) & mask) == mask && c1.and_not (mask) == 0)
+ if (((c1 | c2) & mask) == mask
+ && wi::bit_and_not (c1, mask) == 0)
{
c3 = mask;
break;