aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@redhat.com>2020-04-28 19:12:39 +0200
committerAldy Hernandez <aldyh@redhat.com>2020-04-28 20:14:46 +0200
commit596ec9a19b86df93f9c00f4c325e872520d7b96e (patch)
tree81f77ef2e81a4d6d61676a60fee400f2ac8e4fc1
parented94068fb3604aa0d2022064956bfb7701ffa2b5 (diff)
downloadgcc-596ec9a19b86df93f9c00f4c325e872520d7b96e.zip
gcc-596ec9a19b86df93f9c00f4c325e872520d7b96e.tar.gz
gcc-596ec9a19b86df93f9c00f4c325e872520d7b96e.tar.bz2
Set nonzero from mask if everything else fails.
-rw-r--r--gcc/range-op.cc21
1 files changed, 13 insertions, 8 deletions
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;
}