public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <apinski@marvell.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Pinski <apinski@marvell.com>
Subject: [PATCH 1/3] Improve ssa_name_has_boolean_range slightly
Date: Sat, 2 Sep 2023 08:09:55 -0700	[thread overview]
Message-ID: <20230902150957.845269-1-apinski@marvell.com> (raw)

Right now ssa_name_has_boolean_range compares the range to
range_true_and_false but instead we would get the nonzero bits and
compare that to 1 instead (<=u 1).
The nonzerobits comparison can be done in similar fashion.
Note I think get_nonzero_bits is redundant as the range queury will
return a more accurate version or the same value.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

	* tree-ssanames.cc (ssa_name_has_boolean_range): Improve
	using range's get_nonzero_bits and use `<=u 1`.
---
 gcc/tree-ssanames.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 6c362995c1a..7940d9954d8 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -535,10 +535,11 @@ ssa_name_has_boolean_range (tree op)
     {
       int_range<2> r;
       if (get_range_query (cfun)->range_of_expr (r, op)
-	  && r == range_true_and_false (TREE_TYPE (op)))
+	  && !r.undefined_p ()
+	  && wi::leu_p (r.get_nonzero_bits (), 1))
 	return true;
 
-      if (wi::eq_p (get_nonzero_bits (op), 1))
+      if (wi::leu_p (get_nonzero_bits (op), 1))
 	return true;
     }
 
-- 
2.31.1


             reply	other threads:[~2023-09-02 15:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-02 15:09 Andrew Pinski [this message]
2023-09-02 15:09 ` [PATCH 2/3] MATCH: Improve zero_one_valued_p by using ssa_name_has_boolean_range Andrew Pinski
2023-09-05  6:59   ` Jeff Law
2023-09-02 15:09 ` [PATCH 3/3] MATCH: Replace all uses of ssa_name_has_boolean_range with zero_one_valued_p Andrew Pinski
2023-09-05  7:02   ` Jeff Law
2023-09-05  6:58 ` [PATCH 1/3] Improve ssa_name_has_boolean_range slightly Jeff Law

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=20230902150957.845269-1-apinski@marvell.com \
    --to=apinski@marvell.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).