vr_values::{get,update}_value_range: use value_range API

Message ID 604a1c7d-9a70-e3fb-cef6-79c09216e275@redhat.com
State New
Headers show
Series
  • vr_values::{get,update}_value_range: use value_range API
Related show

Commit Message

Aldy Hernandez Nov. 8, 2018, 12:01 p.m.
As per $SUBJECT.

Depends on get_range_info() API changes I have just submitted.

OK for trunk?

Comments

Richard Biener Nov. 8, 2018, 2 p.m. | #1
On Thu, Nov 8, 2018 at 1:01 PM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> As per $SUBJECT.
>
> Depends on get_range_info() API changes I have just submitted.
>
> OK for trunk?

OK

Patch

commit 01b8d323f896692d2e999b607f4464861d9ccd8f
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Thu Nov 8 12:56:41 2018 +0100

            * vr-values.c (vr_values::get_value_range): Use value_range API
            instead of piecing together ranges.
            (vr_values::update_value_range): Same.

diff --git a/gcc/vr-values.c b/gcc/vr-values.c
index 8c9fd159146..4edc5a467ee 100644
--- a/gcc/vr-values.c
+++ b/gcc/vr-values.c
@@ -121,15 +121,9 @@  vr_values::get_value_range (const_tree var)
 	    set_value_range_to_nonnull (vr, TREE_TYPE (sym));
 	  else if (INTEGRAL_TYPE_P (TREE_TYPE (sym)))
 	    {
-	      wide_int min, max;
-	      value_range_kind rtype = get_range_info (var, &min, &max);
-	      if (rtype == VR_RANGE || rtype == VR_ANTI_RANGE)
-		set_value_range (vr, rtype,
-				 wide_int_to_tree (TREE_TYPE (var), min),
-				 wide_int_to_tree (TREE_TYPE (var), max),
-				 NULL);
-	      else
-		set_value_range_to_varying (vr);
+	      get_range_info (var, *vr);
+	      if (vr->undefined_p ())
+		vr->set_varying ();
 	    }
 	  else
 	    set_value_range_to_varying (vr);
@@ -178,17 +172,10 @@  vr_values::update_value_range (const_tree var, value_range *new_vr)
      factor that in.  */
   if (INTEGRAL_TYPE_P (TREE_TYPE (var)))
     {
-      wide_int min, max;
-      value_range_kind rtype = get_range_info (var, &min, &max);
+      value_range nr;
+      value_range_kind rtype = get_range_info (var, nr);
       if (rtype == VR_RANGE || rtype == VR_ANTI_RANGE)
-	{
-	  tree nr_min, nr_max;
-	  nr_min = wide_int_to_tree (TREE_TYPE (var), min);
-	  nr_max = wide_int_to_tree (TREE_TYPE (var), max);
-	  value_range nr;
-	  nr.set_and_canonicalize (rtype, nr_min, nr_max, NULL);
-	  new_vr->intersect (&nr);
-	}
+	new_vr->intersect (&nr);
     }
 
   /* Update the value range, if necessary.  */