]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Intersect with nonzero bits can indicate change incorrectly.
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 31 Oct 2022 13:53:01 +0000 (09:53 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 1 Nov 2022 13:05:20 +0000 (09:05 -0400)
* value-range.cc (irange::intersect_nonzero_bits): If new
non-zero mask is the same as original, flag no change.

gcc/value-range.cc

index 03b3c4b4a65dae063de33d397fc8375e6a7b6473..3743ec714b31fdc744c0c4e27284ffe4c1b5fb24 100644 (file)
@@ -3017,6 +3017,10 @@ irange::intersect_nonzero_bits (const irange &r)
   if (mask_to_wi (m_nonzero_mask, t) != mask_to_wi (r.m_nonzero_mask, t))
     {
       wide_int nz = get_nonzero_bits () & r.get_nonzero_bits ();
+      // If the nonzero bits did not change, return false.
+      if (nz == get_nonzero_bits ())
+       return false;
+
       m_nonzero_mask = wide_int_to_tree (t, nz);
       if (set_range_from_nonzero_bits ())
        return true;