]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't use range_info_get_range for pointers.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 3 Oct 2023 16:32:10 +0000 (12:32 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 3 Oct 2023 21:15:27 +0000 (17:15 -0400)
Pointers only track null and nonnull, so we need to handle them
specially.

* tree-ssanames.cc (set_range_info): Use get_ptr_info for
pointers rather than range_info_get_range.

gcc/tree-ssanames.cc

index 1eae411ac1c083e6d4f86475504ceac6f01b14f7..0a32444fbdf9f03646bd6b64637a4d6881019aa6 100644 (file)
@@ -420,15 +420,11 @@ set_range_info (tree name, const vrange &r)
 
   // Pick up the current range, or VARYING if none.
   tree type = TREE_TYPE (name);
-  Value_Range tmp (type);
-  if (range_info_p (name))
-    range_info_get_range (name, tmp);
-  else
-    tmp.set_varying (type);
-
   if (POINTER_TYPE_P (type))
     {
-      if (r.nonzero_p () && !tmp.nonzero_p ())
+      struct ptr_info_def *pi = get_ptr_info (name);
+      // If R is nonnull and pi is not, set nonnull.
+      if (r.nonzero_p () && (!pi || pi->pt.null))
        {
          set_ptr_nonnull (name);
          return true;
@@ -436,6 +432,11 @@ set_range_info (tree name, const vrange &r)
       return false;
     }
 
+  Value_Range tmp (type);
+  if (range_info_p (name))
+    range_info_get_range (name, tmp);
+  else
+    tmp.set_varying (type);
   // If the result doesn't change, or is undefined, return false.
   if (!tmp.intersect (r) || tmp.undefined_p ())
     return false;