diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2022-10-04 17:05:10 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2022-10-05 14:21:04 +0200 |
commit | 4c451631f722c9939260a5c2fc209802a47e525f (patch) | |
tree | 16bc0c6ca427cbc8463f93f092c6d848aff557ac /gcc/gimple-range-op.cc | |
parent | ae56d600d223e996054483d7d7033ec8e258d39d (diff) | |
download | gcc-4c451631f722c9939260a5c2fc209802a47e525f.zip gcc-4c451631f722c9939260a5c2fc209802a47e525f.tar.gz gcc-4c451631f722c9939260a5c2fc209802a47e525f.tar.bz2 |
[PR tree-optimization/107052] range-ops: Take into account nonzero mask in popcount.
PR tree-optimization/107052
gcc/ChangeLog:
* gimple-range-op.cc (cfn_popcount::fold_range): Take into account
nonzero bit mask.
Diffstat (limited to 'gcc/gimple-range-op.cc')
-rw-r--r-- | gcc/gimple-range-op.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 5b71d1c..42ebc7d 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -422,15 +422,24 @@ public: virtual bool fold_range (irange &r, tree type, const irange &lh, const irange &rh, relation_kind rel) const { + if (lh.undefined_p ()) + return false; + unsigned prec = TYPE_PRECISION (type); + wide_int nz = lh.get_nonzero_bits (); + wide_int pop = wi::shwi (wi::popcount (nz), prec); // Calculating the popcount of a singleton is trivial. if (lh.singleton_p ()) { - wide_int nz = lh.get_nonzero_bits (); - wide_int pop = wi::shwi (wi::popcount (nz), TYPE_PRECISION (type)); r.set (type, pop, pop); return true; } - return cfn_ffs::fold_range (r, type, lh, rh, rel); + if (cfn_ffs::fold_range (r, type, lh, rh, rel)) + { + int_range<2> tmp (type, wi::zero (prec), pop); + r.intersect (tmp); + return true; + } + return false; } } op_cfn_popcount; |