From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "hernandez, aldy" <aldyh@redhat.com>
Subject: [COMMITTED] Irange::intersect with nonzero bits can indicate change incorrectly.
Date: Tue, 1 Nov 2022 09:19:11 -0400 [thread overview]
Message-ID: <92fa3f27-cfe1-c1f5-6796-365d548159bb@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
irange::intersect returns true if the intersection operation changes the
value. If both ranges had nonzero bits set, intersect_nonzero_bits was
not checking to see if the operation actually changes the bits or not,
it changed the mask and returned true.
Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
[-- Attachment #2: 0001-Intersect-with-nonzero-bits-can-indicate-change-inco.patch --]
[-- Type: text/x-patch, Size: 1015 bytes --]
From 7cc2824e39440dd71a9d2832c51ef260bb36d8ca Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Mon, 31 Oct 2022 09:53:01 -0400
Subject: [PATCH 1/3] Intersect with nonzero bits can indicate change
incorrectly.
* value-range.cc (irange::intersect_nonzero_bits): If new
non-zero mask is the same as original, flag no change.
---
gcc/value-range.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 03b3c4b4a65..3743ec714b3 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -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;
--
2.37.3
reply other threads:[~2022-11-01 13:19 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=92fa3f27-cfe1-c1f5-6796-365d548159bb@redhat.com \
--to=amacleod@redhat.com \
--cc=aldyh@redhat.com \
--cc=gcc-patches@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).