public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Cc: Andrew MacLeod <amacleod@redhat.com>, Aldy Hernandez <aldyh@redhat.com>
Subject: [COMMITTED] Convert compare_nonzero_chars to wide_ints.
Date: Wed, 26 Apr 2023 13:47:49 +0200	[thread overview]
Message-ID: <20230426114752.336928-4-aldyh@redhat.com> (raw)
In-Reply-To: <20230426114752.336928-1-aldyh@redhat.com>

gcc/ChangeLog:

	* tree-ssa-strlen.cc (compare_nonzero_chars): Convert to wide_ints.
---
 gcc/tree-ssa-strlen.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc
index 0bbcb04834f..de785281b27 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -359,10 +359,10 @@ compare_nonzero_chars (strinfo *si, gimple *stmt,
      of the length range are equal return the result of the comparison
      same as in the constant case.  Otherwise return a conservative
      result.  */
-  tree lower = wide_int_to_tree (vr.type (), vr.lower_bound ());
-  tree upper = wide_int_to_tree (vr.type (), vr.upper_bound ());
-  int cmpmin = compare_tree_int (lower, off);
-  if (cmpmin > 0 || tree_int_cst_equal (lower, upper))
+  signop sign = TYPE_SIGN (vr.type ());
+  unsigned prec = TYPE_PRECISION (vr.type ());
+  int cmpmin = wi::cmp (vr.lower_bound (), wi::uhwi (off, prec), sign);
+  if (cmpmin > 0 || vr.singleton_p ())
     return cmpmin;
 
   return -1;
-- 
2.40.0


  parent reply	other threads:[~2023-04-26 11:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-26 11:47 [COMMITTED] Fix swapping of ranges Aldy Hernandez
2023-04-26 11:47 ` [COMMITTED] Replace ad-hoc value_range dumpers with irange::dump Aldy Hernandez
2023-04-26 11:47 ` [COMMITTED] Remove some uses of deprecated irange API Aldy Hernandez
2023-04-26 11:47 ` Aldy Hernandez [this message]
2023-04-26 11:47 ` [COMMITTED] Remove range_int_cst_p Aldy Hernandez
2023-04-26 11:47 ` [COMMITTED] Remove range_has_numeric_bounds_p Aldy Hernandez
2023-04-26 11:47 ` [COMMITTED] Remove legacy range support Aldy Hernandez

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=20230426114752.336928-4-aldyh@redhat.com \
    --to=aldyh@redhat.com \
    --cc=amacleod@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).