diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2020-11-17 10:04:38 -0500 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2020-11-17 11:58:07 -0500 |
commit | a5f9c27bfc4417224e332392bb81a2d733b2b5bf (patch) | |
tree | 4924d184b2ab656e77a14f962af4844954438028 /gcc/range-op.cc | |
parent | c2cf58f0e3a32b803c890ea8daa8d9f550cf9888 (diff) | |
download | gcc-a5f9c27bfc4417224e332392bb81a2d733b2b5bf.zip gcc-a5f9c27bfc4417224e332392bb81a2d733b2b5bf.tar.gz gcc-a5f9c27bfc4417224e332392bb81a2d733b2b5bf.tar.bz2 |
IOR with nonzero, range cannot contain 0.
Remove zero from IOR ranges with non-zero masks.
gcc/
PR tree-optimization/83072
* range-op.cc (wi_optimize_and_or): Remove zero from IOR range when
mask is non-zero.
gcc/testsuite/
* gcc.dg/pr83072.c: New.
Diffstat (limited to 'gcc/range-op.cc')
-rw-r--r-- | gcc/range-op.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/range-op.cc b/gcc/range-op.cc index b746aad..d0adc95 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2163,6 +2163,14 @@ wi_optimize_and_or (irange &r, else gcc_unreachable (); value_range_with_overflow (r, type, res_lb, res_ub); + + // Furthermore, if the mask is non-zero, an IOR cannot contain zero. + if (code == BIT_IOR_EXPR && wi::ne_p (mask, 0)) + { + int_range<2> tmp; + tmp.set_nonzero (type); + r.intersect (tmp); + } return true; } |