public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-1684] Clear nonzero mask when inverting ranges.
Date: Wed, 13 Jul 2022 14:26:11 +0000 (GMT)	[thread overview]
Message-ID: <20220713142611.67D5A385357E@sourceware.org> (raw)

https://gcc.gnu.org/g:554b21edb9ec91a898125d4915d790c6d4b9a688

commit r13-1684-g554b21edb9ec91a898125d4915d790c6d4b9a688
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed Jul 13 12:38:35 2022 +0200

    Clear nonzero mask when inverting ranges.
    
    Every time we set a range we should take into account the nonzero
    mask.  This happens automatically for the set() methods, plus all the
    other assignment, intersect, and union methods.  Unfortunately I
    forgot about the invert code.
    
    Also, for good measure I audited the rest of the setters in
    value_range.cc and plugged the legacy code to pessimize the masks to
    -1 for union/intersect, since we don't support the masks on them (or
    rather, we don't keep very good track of them).
    
    Tested on x86-64 Linux.
    
    gcc/ChangeLog:
    
            * value-range.cc (irange::copy_to_legacy): Set nonzero mask.
            (irange::legacy_intersect): Clear nonzero mask.
            (irange::legacy_union): Same.
            (irange::invert): Same.

Diff:
---
 gcc/value-range.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 2aa973b2af2..528ed547ef3 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -331,6 +331,7 @@ irange::copy_to_legacy (const irange &src)
       m_base[0] = src.m_base[0];
       m_base[1] = src.m_base[1];
       m_kind = src.m_kind;
+      m_nonzero_mask = src.m_nonzero_mask;
       return;
     }
   // Copy multi-range to legacy.
@@ -1336,6 +1337,9 @@ irange::legacy_intersect (irange *vr0, const irange *vr1)
   intersect_ranges (&vr0kind, &vr0min, &vr0max,
 		    vr1->kind (), vr1->min (), vr1->max ());
 
+  // Pessimize nonzero masks, as we don't support them.
+  m_nonzero_mask = NULL;
+
   /* Make sure to canonicalize the result though as the inversion of a
      VR_RANGE can still be a VR_RANGE.  */
   if (vr0kind == VR_UNDEFINED)
@@ -1657,6 +1661,9 @@ irange::legacy_union (irange *vr0, const irange *vr1)
   union_ranges (&vr0kind, &vr0min, &vr0max,
 		vr1->kind (), vr1->min (), vr1->max ());
 
+  // Pessimize nonzero masks, as we don't support them.
+  m_nonzero_mask = NULL;
+
   if (vr0kind == VR_UNDEFINED)
     vr0->set_undefined ();
   else if (vr0kind == VR_VARYING)
@@ -2253,6 +2260,7 @@ irange::invert ()
     }
 
   gcc_checking_assert (!undefined_p () && !varying_p ());
+  m_nonzero_mask = NULL;
 
   // We always need one more set of bounds to represent an inverse, so
   // if we're at the limit, we can't properly represent things.


                 reply	other threads:[~2022-07-13 14:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220713142611.67D5A385357E@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).