]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Convert compare_nonzero_chars to wide_ints.
authorAldy Hernandez <aldyh@redhat.com>
Thu, 2 Mar 2023 15:56:12 +0000 (16:56 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 26 Apr 2023 09:46:06 +0000 (11:46 +0200)
gcc/ChangeLog:

* tree-ssa-strlen.cc (compare_nonzero_chars): Convert to wide_ints.

gcc/tree-ssa-strlen.cc

index 0bbcb04834ff9a28e1bc89a3d5f6c73610ed41e0..de785281b27dc95390e74afb243fb64079a792f0 100644 (file)
@@ -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;