Remove value_range_constant_singleton
diff mbox series

Message ID e3c36c0d-42b8-6932-3b86-309db57f5450@redhat.com
State New
Headers show
Series
  • Remove value_range_constant_singleton
Related show

Commit Message

Aldy Hernandez June 11, 2019, 10:27 a.m. UTC
We already have value_range::singleton_p.  No need for a separate 
external function with the same functionality.

OK?

Comments

Richard Biener June 11, 2019, 1:32 p.m. UTC | #1
On Tue, Jun 11, 2019 at 12:27 PM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> We already have value_range::singleton_p.  No need for a separate
> external function with the same functionality.
>
> OK?

OK.

Shame that there isn't some nicer syntax for

-  return value_range_constant_singleton (get_value_range (op));
+  tree t;
+  if (get_value_range (op)->singleton_p (&t))
+    return t;
+  return NULL;

Richard.

Patch
diff mbox series

commit 42981b54247461fcaa43d14315efa6fd3abbf949
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Jun 4 18:42:33 2019 +0200

    Remove value_range_constant_singleton in favor of value_range::singleton_p.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 815e7546b89..bee0a75a000 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@ 
+2019-06-11  Aldy Hernandez  <aldyh@redhat.com>
+
+	* gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children): Use
+	value_range::singleton_p.
+	* tree-vrp.c (value_range_constant_singleton): Remove.
+	* tree-vrp.h (value_range_constant_singleton): Remove.
+	* vr-values.c (vr_values::singleton): Use
+	value_range::singleton_p.
+
 2019-06-07  Aldy Hernandez  <aldyh@redhat.com>
 
 	* tree-vrp.h (value_range_base::intersect): New.
diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c
index ca6ec1354fd..b7b006abf6c 100644
--- a/gcc/gimple-ssa-evrp.c
+++ b/gcc/gimple-ssa-evrp.c
@@ -109,8 +109,8 @@  evrp_dom_walker::before_dom_children (basic_block bb)
 
       value_range *vr = evrp_range_analyzer.get_value_range (lhs);
       /* Mark PHIs whose lhs we fully propagate for removal.  */
-      tree val = value_range_constant_singleton (vr);
-      if (val && may_propagate_copy (lhs, val))
+      tree val;
+      if (vr->singleton_p (&val) && may_propagate_copy (lhs, val))
 	{
 	  stmts_to_remove.safe_push (phi);
 	  continue;
@@ -158,7 +158,7 @@  evrp_dom_walker::before_dom_children (basic_block bb)
 	      value_range *vr = evrp_range_analyzer.get_value_range (output);
 
 	      /* Mark stmts whose output we fully propagate for removal.  */
-	      if ((val = value_range_constant_singleton (vr))
+	      if (vr->singleton_p (&val)
 		  && may_propagate_copy (output, val)
 		  && !stmt_could_throw_p (cfun, stmt)
 		  && !gimple_has_side_effects (stmt))
@@ -204,8 +204,8 @@  evrp_dom_walker::before_dom_children (basic_block bb)
 	      || virtual_operand_p (arg))
 	    continue;
 	  value_range *vr = evrp_range_analyzer.get_value_range (arg);
-	  tree val = value_range_constant_singleton (vr);
-	  if (val && may_propagate_copy (arg, val))
+	  tree val;
+	  if (vr->singleton_p (&val) && may_propagate_copy (arg, val))
 	    propagate_value (use_p, val);
 	}
     }
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 99c93f8f93b..08e6c6b6111 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -1188,21 +1188,6 @@  range_includes_p (const value_range_base *vr, HOST_WIDE_INT x)
   return vr->may_contain_p (build_int_cst (vr->type (), x));
 }
 
-/* If *VR has a value range that is a single constant value return that,
-   otherwise return NULL_TREE.
-
-   ?? This actually returns TRUE for [&x, &x], so perhaps "constant"
-   is not the best name.  */
-
-tree
-value_range_constant_singleton (const value_range_base *vr)
-{
-  tree result = NULL;
-  if (vr->singleton_p (&result))
-    return result;
-  return NULL;
-}
-
 /* Value range wrapper for wide_int_range_set_zero_nonzero_bits.
 
    Compute MAY_BE_NONZERO and MUST_BE_NONZERO bit masks for range in VR.
diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h
index 255f549a03d..e48cc37bafc 100644
--- a/gcc/tree-vrp.h
+++ b/gcc/tree-vrp.h
@@ -259,7 +259,6 @@  extern bool infer_value_range (gimple *, tree, tree_code *, tree *);
 
 extern bool vrp_bitmap_equal_p (const_bitmap, const_bitmap);
 
-extern tree value_range_constant_singleton (const value_range_base *);
 extern bool range_int_cst_p (const value_range_base *);
 extern bool range_int_cst_singleton_p (const value_range_base *);
 
diff --git a/gcc/vr-values.c b/gcc/vr-values.c
index 27c463b633f..1c05ffb7f17 100644
--- a/gcc/vr-values.c
+++ b/gcc/vr-values.c
@@ -414,7 +414,10 @@  vr_values::singleton (tree op, gimple *stmt ATTRIBUTE_UNUSED)
   if (TREE_CODE (op) != SSA_NAME)
     return NULL_TREE;
 
-  return value_range_constant_singleton (get_value_range (op));
+  tree t;
+  if (get_value_range (op)->singleton_p (&t))
+    return t;
+  return NULL;
 }
 
 /* Return true if op is in a boolean [0, 1] value-range.  */