diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2023-07-25 12:30:42 -0400 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2023-07-26 10:38:37 +0200 |
commit | 5cac2394ef958945d80112b7d18673fce0c93872 (patch) | |
tree | 7ef965dcd457ffd869269f64f92361e1e9744948 | |
parent | 7a48d8d28cc683974057ce9fdfd3fb224ff76641 (diff) | |
download | gcc-5cac2394ef958945d80112b7d18673fce0c93872.zip gcc-5cac2394ef958945d80112b7d18673fce0c93872.tar.gz gcc-5cac2394ef958945d80112b7d18673fce0c93872.tar.bz2 |
[range-ops] Handle bitmasks for unary operators.
It looks like we missed out on bitmasks for unary operators because we
were using bit_value_binop exclusively. This patch hands off to
bit_value_unop when appropriate, thus allowing us to handle ABS and
BIT_NOT_EXPR, and others. Follow-up patches will add the tweaks for the
range-ops entries themselves.
gcc/ChangeLog:
* range-op.cc (update_known_bitmask): Handle unary operators.
-rw-r--r-- | gcc/range-op.cc | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 6b5d4f2..d959a3e 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -385,15 +385,29 @@ update_known_bitmask (irange &r, tree_code code, irange_bitmask lh_bits = lh.get_bitmask (); irange_bitmask rh_bits = rh.get_bitmask (); - bit_value_binop (code, sign, prec, &widest_value, &widest_mask, - TYPE_SIGN (lh.type ()), - TYPE_PRECISION (lh.type ()), - widest_int::from (lh_bits.value (), sign), - widest_int::from (lh_bits.mask (), sign), - TYPE_SIGN (rh.type ()), - TYPE_PRECISION (rh.type ()), - widest_int::from (rh_bits.value (), sign), - widest_int::from (rh_bits.mask (), sign)); + switch (get_gimple_rhs_class (code)) + { + case GIMPLE_UNARY_RHS: + bit_value_unop (code, sign, prec, &widest_value, &widest_mask, + TYPE_SIGN (lh.type ()), + TYPE_PRECISION (lh.type ()), + widest_int::from (lh_bits.value (), sign), + widest_int::from (lh_bits.mask (), sign)); + break; + case GIMPLE_BINARY_RHS: + bit_value_binop (code, sign, prec, &widest_value, &widest_mask, + TYPE_SIGN (lh.type ()), + TYPE_PRECISION (lh.type ()), + widest_int::from (lh_bits.value (), sign), + widest_int::from (lh_bits.mask (), sign), + TYPE_SIGN (rh.type ()), + TYPE_PRECISION (rh.type ()), + widest_int::from (rh_bits.value (), sign), + widest_int::from (rh_bits.mask (), sign)); + break; + default: + gcc_unreachable (); + } wide_int mask = wide_int::from (widest_mask, prec, sign); wide_int value = wide_int::from (widest_value, prec, sign); |