From 596ec9a19b86df93f9c00f4c325e872520d7b96e Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Tue, 28 Apr 2020 19:12:39 +0200 Subject: Set nonzero from mask if everything else fails. --- gcc/range-op.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'gcc') diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 057b687..26353c1 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2159,6 +2159,15 @@ wide_int masked_increment (const wide_int &val_in, const wide_int &mask, const wide_int &sgnbit, unsigned int prec); +static void +set_nonzero_range_from_mask (irange &r, tree type, const irange &lhs) +{ + if (!lhs.contains_p (build_zero_cst (type))) + r = range_nonzero (type); + else + r.set_varying (type); +} + void operator_bitwise_and::simple_op1_range_solver (irange &r, tree type, const irange &lhs, @@ -2176,12 +2185,7 @@ operator_bitwise_and::simple_op1_range_solver (irange &r, tree type, } if (!op2.singleton_p ()) { - // We bail on anything that's not a singleton mask, but at least - // we can determine non-zeroness. - if (!lhs.contains_p (build_zero_cst (type))) - r = range_nonzero (type); - else - r.set_varying (type); + set_nonzero_range_from_mask (r, type, lhs); return; } unsigned int nprec = TYPE_PRECISION (type); @@ -2266,7 +2270,8 @@ operator_bitwise_and::op1_range (irange &r, tree type, { simple_op1_range_solver (r, type, lhs, op2); if (r.undefined_p ()) - return false; + set_nonzero_range_from_mask (r, type, lhs); + return !r.varying_p (); } else { @@ -2281,7 +2286,7 @@ operator_bitwise_and::op1_range (irange &r, tree type, r.union_ (res); } if (r.undefined_p ()) - r.set_varying (type); + set_nonzero_range_from_mask (r, type, lhs); } return true; } -- cgit v1.1