]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ranger: More efficient zero/nonzero check.
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 27 Sep 2021 22:53:54 +0000 (18:53 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 6 Oct 2021 13:11:50 +0000 (09:11 -0400)
A recent change introduced a frequent check for zero and non-zero which has
caused a lot of extra temporary trees to be created.  Make the check more
efficent as it is always a pointer and thus unsigned.

* gimple-range-cache.cc (non_null_ref::adjust_range): Check for
zero and non-zero more efficently.

gcc/gimple-range-cache.cc

index 61043d3f37507056e4618f76c2124aede3169c71..91dd5a5c0871e9deadcd6c405f6f56a6c84f556b 100644 (file)
@@ -98,9 +98,10 @@ non_null_ref::adjust_range (irange &r, tree name, basic_block bb,
     return false;
 
   // We only care about the null / non-null property of pointers.
-  if (!POINTER_TYPE_P (TREE_TYPE (name)) || r.zero_p () || r.nonzero_p ())
+  if (!POINTER_TYPE_P (TREE_TYPE (name)))
+    return false;
+  if (r.undefined_p () || r.lower_bound () != 0 || r.upper_bound () == 0)
     return false;
-
   // Check if pointers have any non-null dereferences.
   if (non_null_deref_p (name, bb, search_dom))
     {