public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
[parent not found: <20230227135827.802E8385840A@sourceware.org>]
* [PATCH] Fixup possible VR_ANTI_RANGE value_range issues
@ 2023-02-27 13:58 Richard Biener
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Biener @ 2023-02-27 13:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: aldyh

After fixing PR107561 the following avoids looking at VR_ANTI_RANGE
ranges where it doesn't seem obvious the code does the correct
thing here (lower_bound and upper_bound do not work as expected).

Bootstrapped and tested on x86_64-unknown-linux-gnu.

OK?

Thanks,
Richard.

	* gimple-ssa-sprintf.cc (get_int_range): Avoid VR_ANTI_RANGE
	by using range_int_cst_p.
	(format_integer): Likewise.
	(handle_printf_call): Guard against VR_ANTI_RANGE.
	* graphite-sese-to-poly.cc (add_param_constraints): Likewise.
	* tree-ssa-strlen.cc (set_strlen_range): Likewise.
---
 gcc/gimple-ssa-sprintf.cc    | 6 +++---
 gcc/graphite-sese-to-poly.cc | 2 +-
 gcc/tree-ssa-strlen.cc       | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple-ssa-sprintf.cc b/gcc/gimple-ssa-sprintf.cc
index 18975708d2c..61974072f62 100644
--- a/gcc/gimple-ssa-sprintf.cc
+++ b/gcc/gimple-ssa-sprintf.cc
@@ -1082,7 +1082,7 @@ get_int_range (tree arg, gimple *stmt,
 	  value_range vr;
 	  query->range_of_expr (vr, arg, stmt);
 
-	  if (!vr.undefined_p () && !vr.varying_p ())
+	  if (range_int_cst_p (&vr))
 	    {
 	      HOST_WIDE_INT type_min
 		= (TYPE_UNSIGNED (argtype)
@@ -1391,7 +1391,7 @@ format_integer (const directive &dir, tree arg, pointer_query &ptr_qry)
       value_range vr;
       ptr_qry.rvals->range_of_expr (vr, arg, dir.info->callstmt);
 
-      if (!vr.varying_p () && !vr.undefined_p ())
+      if (range_int_cst_p (&vr))
 	{
 	  argmin = wide_int_to_tree (TREE_TYPE (arg), vr.lower_bound ());
 	  argmax = wide_int_to_tree (TREE_TYPE (arg), vr.upper_bound ());
@@ -4623,7 +4623,7 @@ handle_printf_call (gimple_stmt_iterator *gsi, pointer_query &ptr_qry)
 	  value_range vr;
 	  ptr_qry.rvals->range_of_expr (vr, size, info.callstmt);
 
-	  if (!vr.undefined_p ())
+	  if (!vr.undefined_p () && vr.kind () != VR_ANTI_RANGE)
 	    {
 	      tree type = TREE_TYPE (size);
 	      tree tmin = wide_int_to_tree (type, vr.lower_bound ());
diff --git a/gcc/graphite-sese-to-poly.cc b/gcc/graphite-sese-to-poly.cc
index fbe7667380a..b89262640ac 100644
--- a/gcc/graphite-sese-to-poly.cc
+++ b/gcc/graphite-sese-to-poly.cc
@@ -426,7 +426,7 @@ add_param_constraints (scop_p scop, graphite_dim_t p, tree parameter)
 
   if (INTEGRAL_TYPE_P (type)
       && get_range_query (cfun)->range_of_expr (r, parameter)
-      && !r.undefined_p ())
+      && range_int_cst_p (&r))
     {
       min = r.lower_bound ();
       max = r.upper_bound ();
diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc
index 7508c1768a5..e1230522564 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -1936,7 +1936,7 @@ set_strlen_range (tree lhs, wide_int min, wide_int max,
 	{
 	  value_range r;
 	  get_range_query (cfun)->range_of_expr (r, bound);
-	  if (!r.undefined_p ())
+	  if (range_int_cst_p (&r))
 	    {
 	      /* For a bound in a known range, adjust the range determined
 		 above as necessary.  For a bound in some anti-range or
-- 
2.35.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-11 16:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <09219.123022708581201997@us-mta-652.us.mimecast.lan>
2023-02-27 16:08 ` [PATCH] Fixup possible VR_ANTI_RANGE value_range issues Aldy Hernandez
2023-02-28  9:41   ` Richard Biener
2023-03-01 10:01     ` Aldy Hernandez
2023-03-01 10:12       ` Richard Biener
2023-03-01 10:28         ` Aldy Hernandez
     [not found] <20230227135827.802E8385840A@sourceware.org>
2023-03-11 16:16 ` Jeff Law
2023-02-27 13:58 Richard Biener

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).