public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aldyh/heads/ranger-relational)] Pick up global ranges for default SSA names from gimple_range_global.
@ 2021-04-22 20:09 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-04-22 20:09 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:97db4efe7f055248cc64974991835ba9000a42bf

commit 97db4efe7f055248cc64974991835ba9000a42bf
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu Apr 22 12:05:14 2021 +0200

    Pick up global ranges for default SSA names from gimple_range_global.

Diff:
---
 gcc/gimple-range.h | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h
index a0cec71582d..2bbd387c54f 100644
--- a/gcc/gimple-range.h
+++ b/gcc/gimple-range.h
@@ -132,20 +132,40 @@ gimple_range_global (tree name)
 {
   gcc_checking_assert (gimple_range_ssa_p (name));
   tree type = TREE_TYPE (name);
+
 #if 0
   // Reenable picking up global ranges when we are OK failing tests that look
   // for builtin_unreachable in the code, like
   // RUNTESTFLAGS=dg.exp=pr61034.C check-g++
   // pre-optimizations (inlining) set a global range which causes the ranger
   // to remove the condition which leads to builtin_unreachable.
-  if (!POINTER_TYPE_P (type) && SSA_NAME_RANGE_INFO (name))
+#endif
+
+  // ?? Adapted from vr_values::get_lattice_entry().
+  // Use a range from an SSA_NAME's available range.
+  tree sym = SSA_NAME_VAR (name);
+  if (SSA_NAME_IS_DEFAULT_DEF (name) && TREE_CODE (sym) == PARM_DECL)
     {
-      // Return a range from an SSA_NAME's available range.
-      wide_int min, max;
-      enum value_range_kind kind = get_range_info (name, &min, &max);
-      return value_range (type, min, max, kind);
+      // Try to use the "nonnull" attribute to create ~[0, 0]
+      // anti-ranges for pointers.  Note that this is only valid with
+      // default definitions of PARM_DECLs.
+      if (POINTER_TYPE_P (type)
+	  && (nonnull_arg_p (sym) || get_ptr_nonnull (name)))
+	{
+	  value_range r;
+	  r.set_nonzero (type);
+	  return r;
+	}
+      else if (INTEGRAL_TYPE_P (type))
+	{
+	  value_range r;
+	  get_range_info (name, r);
+	  if (r.undefined_p ())
+	    r.set_varying (type);
+	  return r;
+	}
     }
-#endif
+
   // If this is a local automatic with no definition, use undefined for a
   // starting value.
   if (SSA_NAME_IS_DEFAULT_DEF (name)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-22 20:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-22 20:09 [gcc(refs/users/aldyh/heads/ranger-relational)] Pick up global ranges for default SSA names from gimple_range_global Aldy Hernandez

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