diff mbox series

Convert remaining uses of value_range in ipa-*.cc to Value_Range.

Message ID 20230522185622.537454-3-aldyh@redhat.com
State New
Headers show
Series Convert remaining uses of value_range in ipa-*.cc to Value_Range. | expand

Commit Message

Aldy Hernandez May 22, 2023, 6:56 p.m. UTC
Minor cleanups to get rid of value_range in IPA.  There's only one left,
but it's in the switch code which is integer specific.

OK?

gcc/ChangeLog:

	* ipa-cp.cc (decide_whether_version_node): Adjust comment.
	* ipa-fnsummary.cc (evaluate_conditions_for_known_args): Adjust
	for Value_Range.
	(set_switch_stmt_execution_predicate): Same.
	* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Same.
---
 gcc/ipa-cp.cc        |  3 +--
 gcc/ipa-fnsummary.cc | 22 ++++++++++++++--------
 gcc/ipa-prop.cc      |  9 +++------
 3 files changed, 18 insertions(+), 16 deletions(-)

Comments

Aldy Hernandez June 14, 2023, 12:10 p.m. UTC | #1
PING

On Mon, May 22, 2023 at 8:56 PM Aldy Hernandez <aldyh@redhat.com> wrote:
>
> Minor cleanups to get rid of value_range in IPA.  There's only one left,
> but it's in the switch code which is integer specific.
>
> OK?
>
> gcc/ChangeLog:
>
>         * ipa-cp.cc (decide_whether_version_node): Adjust comment.
>         * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Adjust
>         for Value_Range.
>         (set_switch_stmt_execution_predicate): Same.
>         * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Same.
> ---
>  gcc/ipa-cp.cc        |  3 +--
>  gcc/ipa-fnsummary.cc | 22 ++++++++++++++--------
>  gcc/ipa-prop.cc      |  9 +++------
>  3 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
> index 03273666ea2..2e64415096e 100644
> --- a/gcc/ipa-cp.cc
> +++ b/gcc/ipa-cp.cc
> @@ -6287,8 +6287,7 @@ decide_whether_version_node (struct cgraph_node *node)
>             {
>               /* If some values generated for self-recursive calls with
>                  arithmetic jump functions fall outside of the known
> -                value_range for the parameter, we can skip them.  VR interface
> -                supports this only for integers now.  */
> +                range for the parameter, we can skip them.  */
>               if (TREE_CODE (val->value) == INTEGER_CST
>                   && !plats->m_value_range.bottom_p ()
>                   && !ipa_range_contains_p (plats->m_value_range.m_vr,
> diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
> index 0474af8991e..1ce8501fe85 100644
> --- a/gcc/ipa-fnsummary.cc
> +++ b/gcc/ipa-fnsummary.cc
> @@ -488,19 +488,20 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
>                   if (vr.varying_p () || vr.undefined_p ())
>                     break;
>
> -                 value_range res;
> +                 Value_Range res (op->type);
>                   if (!op->val[0])
>                     {
> +                     Value_Range varying (op->type);
> +                     varying.set_varying (op->type);
>                       range_op_handler handler (op->code, op->type);
>                       if (!handler
>                           || !res.supports_type_p (op->type)
> -                         || !handler.fold_range (res, op->type, vr,
> -                                                 value_range (op->type)))
> +                         || !handler.fold_range (res, op->type, vr, varying))
>                         res.set_varying (op->type);
>                     }
>                   else if (!op->val[1])
>                     {
> -                     value_range op0;
> +                     Value_Range op0 (op->type);
>                       range_op_handler handler (op->code, op->type);
>
>                       ipa_range_set_and_normalize (op0, op->val[0]);
> @@ -518,14 +519,14 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
>                 }
>               if (!vr.varying_p () && !vr.undefined_p ())
>                 {
> -                 value_range res;
> -                 value_range val_vr;
> +                 int_range<2> res;
> +                 Value_Range val_vr (TREE_TYPE (c->val));
>                   range_op_handler handler (c->code, boolean_type_node);
>
>                   ipa_range_set_and_normalize (val_vr, c->val);
>
>                   if (!handler
> -                     || !res.supports_type_p (boolean_type_node)
> +                     || !val_vr.supports_type_p (TREE_TYPE (c->val))
>                       || !handler.fold_range (res, boolean_type_node, vr, val_vr))
>                     res.set_varying (boolean_type_node);
>
> @@ -1687,12 +1688,17 @@ set_switch_stmt_execution_predicate (struct ipa_func_body_info *fbi,
>    int bound_limit = opt_for_fn (fbi->node->decl,
>                                 param_ipa_max_switch_predicate_bounds);
>    int bound_count = 0;
> -  value_range vr;
> +  // This can safely be an integer range, as switches can only hold
> +  // integers.
> +  int_range<2> vr;
>
>    get_range_query (cfun)->range_of_expr (vr, op);
>    if (vr.undefined_p ())
>      vr.set_varying (TREE_TYPE (op));
>    tree vr_min, vr_max;
> +  // ?? This entire function could use a rewrite to use the irange
> +  // API, instead of trying to recreate its intersection/union logic.
> +  // Any use of get_legacy_range() is a serious code smell.
>    value_range_kind vr_type = get_legacy_range (vr, vr_min, vr_max);
>    wide_int vr_wmin = wi::to_wide (vr_min);
>    wide_int vr_wmax = wi::to_wide (vr_max);
> diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
> index 6383bc11e0a..5f9e6dbbff2 100644
> --- a/gcc/ipa-prop.cc
> +++ b/gcc/ipa-prop.cc
> @@ -2348,7 +2348,6 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
>    gcall *call = cs->call_stmt;
>    int n, arg_num = gimple_call_num_args (call);
>    bool useful_context = false;
> -  value_range vr;
>
>    if (arg_num == 0 || args->jump_functions)
>      return;
> @@ -2379,6 +2378,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
>             useful_context = true;
>         }
>
> +      Value_Range vr (TREE_TYPE (arg));
>        if (POINTER_TYPE_P (TREE_TYPE (arg)))
>         {
>           bool addr_nonzero = false;
> @@ -2404,14 +2404,11 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
>         {
>           if (TREE_CODE (arg) == SSA_NAME
>               && param_type
> -             /* Limit the ranger query to integral types as the rest
> -                of this file uses value_range's, which only hold
> -                integers and pointers.  */
> -             && irange::supports_p (TREE_TYPE (arg))
> +             && Value_Range::supports_type_p (TREE_TYPE (arg))
>               && get_range_query (cfun)->range_of_expr (vr, arg)
>               && !vr.undefined_p ())
>             {
> -             value_range resvr = vr;
> +             Value_Range resvr (vr);
>               range_cast (resvr, param_type);
>               if (!resvr.undefined_p () && !resvr.varying_p ())
>                 ipa_set_jfunc_vr (jfunc, resvr);
> --
> 2.40.1
>
Aldy Hernandez June 22, 2023, 5:49 a.m. UTC | #2
Ping*2

On Wed, Jun 14, 2023, 14:10 Aldy Hernandez <aldyh@redhat.com> wrote:

> PING
>
> On Mon, May 22, 2023 at 8:56 PM Aldy Hernandez <aldyh@redhat.com> wrote:
> >
> > Minor cleanups to get rid of value_range in IPA.  There's only one left,
> > but it's in the switch code which is integer specific.
> >
> > OK?
> >
> > gcc/ChangeLog:
> >
> >         * ipa-cp.cc (decide_whether_version_node): Adjust comment.
> >         * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Adjust
> >         for Value_Range.
> >         (set_switch_stmt_execution_predicate): Same.
> >         * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Same.
> > ---
> >  gcc/ipa-cp.cc        |  3 +--
> >  gcc/ipa-fnsummary.cc | 22 ++++++++++++++--------
> >  gcc/ipa-prop.cc      |  9 +++------
> >  3 files changed, 18 insertions(+), 16 deletions(-)
> >
> > diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
> > index 03273666ea2..2e64415096e 100644
> > --- a/gcc/ipa-cp.cc
> > +++ b/gcc/ipa-cp.cc
> > @@ -6287,8 +6287,7 @@ decide_whether_version_node (struct cgraph_node
> *node)
> >             {
> >               /* If some values generated for self-recursive calls with
> >                  arithmetic jump functions fall outside of the known
> > -                value_range for the parameter, we can skip them.  VR
> interface
> > -                supports this only for integers now.  */
> > +                range for the parameter, we can skip them.  */
> >               if (TREE_CODE (val->value) == INTEGER_CST
> >                   && !plats->m_value_range.bottom_p ()
> >                   && !ipa_range_contains_p (plats->m_value_range.m_vr,
> > diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
> > index 0474af8991e..1ce8501fe85 100644
> > --- a/gcc/ipa-fnsummary.cc
> > +++ b/gcc/ipa-fnsummary.cc
> > @@ -488,19 +488,20 @@ evaluate_conditions_for_known_args (struct
> cgraph_node *node,
> >                   if (vr.varying_p () || vr.undefined_p ())
> >                     break;
> >
> > -                 value_range res;
> > +                 Value_Range res (op->type);
> >                   if (!op->val[0])
> >                     {
> > +                     Value_Range varying (op->type);
> > +                     varying.set_varying (op->type);
> >                       range_op_handler handler (op->code, op->type);
> >                       if (!handler
> >                           || !res.supports_type_p (op->type)
> > -                         || !handler.fold_range (res, op->type, vr,
> > -                                                 value_range
> (op->type)))
> > +                         || !handler.fold_range (res, op->type, vr,
> varying))
> >                         res.set_varying (op->type);
> >                     }
> >                   else if (!op->val[1])
> >                     {
> > -                     value_range op0;
> > +                     Value_Range op0 (op->type);
> >                       range_op_handler handler (op->code, op->type);
> >
> >                       ipa_range_set_and_normalize (op0, op->val[0]);
> > @@ -518,14 +519,14 @@ evaluate_conditions_for_known_args (struct
> cgraph_node *node,
> >                 }
> >               if (!vr.varying_p () && !vr.undefined_p ())
> >                 {
> > -                 value_range res;
> > -                 value_range val_vr;
> > +                 int_range<2> res;
> > +                 Value_Range val_vr (TREE_TYPE (c->val));
> >                   range_op_handler handler (c->code, boolean_type_node);
> >
> >                   ipa_range_set_and_normalize (val_vr, c->val);
> >
> >                   if (!handler
> > -                     || !res.supports_type_p (boolean_type_node)
> > +                     || !val_vr.supports_type_p (TREE_TYPE (c->val))
> >                       || !handler.fold_range (res, boolean_type_node,
> vr, val_vr))
> >                     res.set_varying (boolean_type_node);
> >
> > @@ -1687,12 +1688,17 @@ set_switch_stmt_execution_predicate (struct
> ipa_func_body_info *fbi,
> >    int bound_limit = opt_for_fn (fbi->node->decl,
> >                                 param_ipa_max_switch_predicate_bounds);
> >    int bound_count = 0;
> > -  value_range vr;
> > +  // This can safely be an integer range, as switches can only hold
> > +  // integers.
> > +  int_range<2> vr;
> >
> >    get_range_query (cfun)->range_of_expr (vr, op);
> >    if (vr.undefined_p ())
> >      vr.set_varying (TREE_TYPE (op));
> >    tree vr_min, vr_max;
> > +  // ?? This entire function could use a rewrite to use the irange
> > +  // API, instead of trying to recreate its intersection/union logic.
> > +  // Any use of get_legacy_range() is a serious code smell.
> >    value_range_kind vr_type = get_legacy_range (vr, vr_min, vr_max);
> >    wide_int vr_wmin = wi::to_wide (vr_min);
> >    wide_int vr_wmax = wi::to_wide (vr_max);
> > diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
> > index 6383bc11e0a..5f9e6dbbff2 100644
> > --- a/gcc/ipa-prop.cc
> > +++ b/gcc/ipa-prop.cc
> > @@ -2348,7 +2348,6 @@ ipa_compute_jump_functions_for_edge (struct
> ipa_func_body_info *fbi,
> >    gcall *call = cs->call_stmt;
> >    int n, arg_num = gimple_call_num_args (call);
> >    bool useful_context = false;
> > -  value_range vr;
> >
> >    if (arg_num == 0 || args->jump_functions)
> >      return;
> > @@ -2379,6 +2378,7 @@ ipa_compute_jump_functions_for_edge (struct
> ipa_func_body_info *fbi,
> >             useful_context = true;
> >         }
> >
> > +      Value_Range vr (TREE_TYPE (arg));
> >        if (POINTER_TYPE_P (TREE_TYPE (arg)))
> >         {
> >           bool addr_nonzero = false;
> > @@ -2404,14 +2404,11 @@ ipa_compute_jump_functions_for_edge (struct
> ipa_func_body_info *fbi,
> >         {
> >           if (TREE_CODE (arg) == SSA_NAME
> >               && param_type
> > -             /* Limit the ranger query to integral types as the rest
> > -                of this file uses value_range's, which only hold
> > -                integers and pointers.  */
> > -             && irange::supports_p (TREE_TYPE (arg))
> > +             && Value_Range::supports_type_p (TREE_TYPE (arg))
> >               && get_range_query (cfun)->range_of_expr (vr, arg)
> >               && !vr.undefined_p ())
> >             {
> > -             value_range resvr = vr;
> > +             Value_Range resvr (vr);
> >               range_cast (resvr, param_type);
> >               if (!resvr.undefined_p () && !resvr.varying_p ())
> >                 ipa_set_jfunc_vr (jfunc, resvr);
> > --
> > 2.40.1
> >
>
Martin Jambor June 26, 2023, 4:41 p.m. UTC | #3
Hi,

On Mon, May 22 2023, Aldy Hernandez via Gcc-patches wrote:
> Minor cleanups to get rid of value_range in IPA.  There's only one left,
> but it's in the switch code which is integer specific.
>
> OK?

With the same request that...

>
> gcc/ChangeLog:
>
> 	* ipa-cp.cc (decide_whether_version_node): Adjust comment.
> 	* ipa-fnsummary.cc (evaluate_conditions_for_known_args): Adjust
> 	for Value_Range.
> 	(set_switch_stmt_execution_predicate): Same.
> 	* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Same.
> ---
>  gcc/ipa-cp.cc        |  3 +--
>  gcc/ipa-fnsummary.cc | 22 ++++++++++++++--------
>  gcc/ipa-prop.cc      |  9 +++------
>  3 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
> index 03273666ea2..2e64415096e 100644
> --- a/gcc/ipa-cp.cc
> +++ b/gcc/ipa-cp.cc
> @@ -6287,8 +6287,7 @@ decide_whether_version_node (struct cgraph_node *node)
>  	    {
>  	      /* If some values generated for self-recursive calls with
>  		 arithmetic jump functions fall outside of the known
> -		 value_range for the parameter, we can skip them.  VR interface
> -		 supports this only for integers now.  */
> +		 range for the parameter, we can skip them.  */
>  	      if (TREE_CODE (val->value) == INTEGER_CST
>  		  && !plats->m_value_range.bottom_p ()
>  		  && !ipa_range_contains_p (plats->m_value_range.m_vr,
> diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
> index 0474af8991e..1ce8501fe85 100644
> --- a/gcc/ipa-fnsummary.cc
> +++ b/gcc/ipa-fnsummary.cc
> @@ -488,19 +488,20 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
>  		  if (vr.varying_p () || vr.undefined_p ())
>  		    break;
>  
> -		  value_range res;
> +		  Value_Range res (op->type);
>  		  if (!op->val[0])
>  		    {
> +		      Value_Range varying (op->type);
> +		      varying.set_varying (op->type);
>  		      range_op_handler handler (op->code, op->type);
>  		      if (!handler
>  			  || !res.supports_type_p (op->type)
> -			  || !handler.fold_range (res, op->type, vr,
> -						  value_range (op->type)))
> +			  || !handler.fold_range (res, op->type, vr, varying))
>  			res.set_varying (op->type);
>  		    }
>  		  else if (!op->val[1])
>  		    {
> -		      value_range op0;
> +		      Value_Range op0 (op->type);
>  		      range_op_handler handler (op->code, op->type);
>  
>  		      ipa_range_set_and_normalize (op0, op->val[0]);
> @@ -518,14 +519,14 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
>  		}
>  	      if (!vr.varying_p () && !vr.undefined_p ())
>  		{
> -		  value_range res;
> -		  value_range val_vr;
> +		  int_range<2> res;
> +		  Value_Range val_vr (TREE_TYPE (c->val));
>  		  range_op_handler handler (c->code, boolean_type_node);
>  
>  		  ipa_range_set_and_normalize (val_vr, c->val);
>  
>  		  if (!handler
> -		      || !res.supports_type_p (boolean_type_node)
> +		      || !val_vr.supports_type_p (TREE_TYPE (c->val))
>  		      || !handler.fold_range (res, boolean_type_node, vr, val_vr))
>  		    res.set_varying (boolean_type_node);
>  
> @@ -1687,12 +1688,17 @@ set_switch_stmt_execution_predicate (struct ipa_func_body_info *fbi,
>    int bound_limit = opt_for_fn (fbi->node->decl,
>  				param_ipa_max_switch_predicate_bounds);
>    int bound_count = 0;
> -  value_range vr;
> +  // This can safely be an integer range, as switches can only hold
> +  // integers.
> +  int_range<2> vr;
>  
>    get_range_query (cfun)->range_of_expr (vr, op);
>    if (vr.undefined_p ())
>      vr.set_varying (TREE_TYPE (op));
>    tree vr_min, vr_max;
> +  // ?? This entire function could use a rewrite to use the irange
> +  // API, instead of trying to recreate its intersection/union logic.
> +  // Any use of get_legacy_range() is a serious code smell.

you replace "??" with TODO, because that is presumably what you mean.

OK with that change.

Thanks,

Martin


>    value_range_kind vr_type = get_legacy_range (vr, vr_min, vr_max);
>    wide_int vr_wmin = wi::to_wide (vr_min);
>    wide_int vr_wmax = wi::to_wide (vr_max);
> diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
> index 6383bc11e0a..5f9e6dbbff2 100644
> --- a/gcc/ipa-prop.cc
> +++ b/gcc/ipa-prop.cc
> @@ -2348,7 +2348,6 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
>    gcall *call = cs->call_stmt;
>    int n, arg_num = gimple_call_num_args (call);
>    bool useful_context = false;
> -  value_range vr;
>  
>    if (arg_num == 0 || args->jump_functions)
>      return;
> @@ -2379,6 +2378,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
>  	    useful_context = true;
>  	}
>  
> +      Value_Range vr (TREE_TYPE (arg));
>        if (POINTER_TYPE_P (TREE_TYPE (arg)))
>  	{
>  	  bool addr_nonzero = false;
> @@ -2404,14 +2404,11 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
>  	{
>  	  if (TREE_CODE (arg) == SSA_NAME
>  	      && param_type
> -	      /* Limit the ranger query to integral types as the rest
> -		 of this file uses value_range's, which only hold
> -		 integers and pointers.  */
> -	      && irange::supports_p (TREE_TYPE (arg))
> +	      && Value_Range::supports_type_p (TREE_TYPE (arg))
>  	      && get_range_query (cfun)->range_of_expr (vr, arg)
>  	      && !vr.undefined_p ())
>  	    {
> -	      value_range resvr = vr;
> +	      Value_Range resvr (vr);
>  	      range_cast (resvr, param_type);
>  	      if (!resvr.undefined_p () && !resvr.varying_p ())
>  		ipa_set_jfunc_vr (jfunc, resvr);
> -- 
> 2.40.1
diff mbox series

Patch

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 03273666ea2..2e64415096e 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -6287,8 +6287,7 @@  decide_whether_version_node (struct cgraph_node *node)
 	    {
 	      /* If some values generated for self-recursive calls with
 		 arithmetic jump functions fall outside of the known
-		 value_range for the parameter, we can skip them.  VR interface
-		 supports this only for integers now.  */
+		 range for the parameter, we can skip them.  */
 	      if (TREE_CODE (val->value) == INTEGER_CST
 		  && !plats->m_value_range.bottom_p ()
 		  && !ipa_range_contains_p (plats->m_value_range.m_vr,
diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
index 0474af8991e..1ce8501fe85 100644
--- a/gcc/ipa-fnsummary.cc
+++ b/gcc/ipa-fnsummary.cc
@@ -488,19 +488,20 @@  evaluate_conditions_for_known_args (struct cgraph_node *node,
 		  if (vr.varying_p () || vr.undefined_p ())
 		    break;
 
-		  value_range res;
+		  Value_Range res (op->type);
 		  if (!op->val[0])
 		    {
+		      Value_Range varying (op->type);
+		      varying.set_varying (op->type);
 		      range_op_handler handler (op->code, op->type);
 		      if (!handler
 			  || !res.supports_type_p (op->type)
-			  || !handler.fold_range (res, op->type, vr,
-						  value_range (op->type)))
+			  || !handler.fold_range (res, op->type, vr, varying))
 			res.set_varying (op->type);
 		    }
 		  else if (!op->val[1])
 		    {
-		      value_range op0;
+		      Value_Range op0 (op->type);
 		      range_op_handler handler (op->code, op->type);
 
 		      ipa_range_set_and_normalize (op0, op->val[0]);
@@ -518,14 +519,14 @@  evaluate_conditions_for_known_args (struct cgraph_node *node,
 		}
 	      if (!vr.varying_p () && !vr.undefined_p ())
 		{
-		  value_range res;
-		  value_range val_vr;
+		  int_range<2> res;
+		  Value_Range val_vr (TREE_TYPE (c->val));
 		  range_op_handler handler (c->code, boolean_type_node);
 
 		  ipa_range_set_and_normalize (val_vr, c->val);
 
 		  if (!handler
-		      || !res.supports_type_p (boolean_type_node)
+		      || !val_vr.supports_type_p (TREE_TYPE (c->val))
 		      || !handler.fold_range (res, boolean_type_node, vr, val_vr))
 		    res.set_varying (boolean_type_node);
 
@@ -1687,12 +1688,17 @@  set_switch_stmt_execution_predicate (struct ipa_func_body_info *fbi,
   int bound_limit = opt_for_fn (fbi->node->decl,
 				param_ipa_max_switch_predicate_bounds);
   int bound_count = 0;
-  value_range vr;
+  // This can safely be an integer range, as switches can only hold
+  // integers.
+  int_range<2> vr;
 
   get_range_query (cfun)->range_of_expr (vr, op);
   if (vr.undefined_p ())
     vr.set_varying (TREE_TYPE (op));
   tree vr_min, vr_max;
+  // ?? This entire function could use a rewrite to use the irange
+  // API, instead of trying to recreate its intersection/union logic.
+  // Any use of get_legacy_range() is a serious code smell.
   value_range_kind vr_type = get_legacy_range (vr, vr_min, vr_max);
   wide_int vr_wmin = wi::to_wide (vr_min);
   wide_int vr_wmax = wi::to_wide (vr_max);
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index 6383bc11e0a..5f9e6dbbff2 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -2348,7 +2348,6 @@  ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
   gcall *call = cs->call_stmt;
   int n, arg_num = gimple_call_num_args (call);
   bool useful_context = false;
-  value_range vr;
 
   if (arg_num == 0 || args->jump_functions)
     return;
@@ -2379,6 +2378,7 @@  ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
 	    useful_context = true;
 	}
 
+      Value_Range vr (TREE_TYPE (arg));
       if (POINTER_TYPE_P (TREE_TYPE (arg)))
 	{
 	  bool addr_nonzero = false;
@@ -2404,14 +2404,11 @@  ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
 	{
 	  if (TREE_CODE (arg) == SSA_NAME
 	      && param_type
-	      /* Limit the ranger query to integral types as the rest
-		 of this file uses value_range's, which only hold
-		 integers and pointers.  */
-	      && irange::supports_p (TREE_TYPE (arg))
+	      && Value_Range::supports_type_p (TREE_TYPE (arg))
 	      && get_range_query (cfun)->range_of_expr (vr, arg)
 	      && !vr.undefined_p ())
 	    {
-	      value_range resvr = vr;
+	      Value_Range resvr (vr);
 	      range_cast (resvr, param_type);
 	      if (!resvr.undefined_p () && !resvr.varying_p ())
 		ipa_set_jfunc_vr (jfunc, resvr);