From 8b2181a415fda05c48a13f915cc42214462d19cb Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Thu, 16 Feb 2023 14:25:52 +0100 Subject: Replace vrp_val* with wide_ints. This patch removes all uses of vrp_val_{min,max} in favor for a irange_val_* which are wide_int based. This will leave only one use of vrp_val_* which returns trees in range_of_ssa_name_with_loop_info() because it needs to work with non-integers (floats, etc). In a follow-up patch, this function will also be cleaned up such that vrp_val_* can be deleted. The functions min_limit and max_limit in range-op.cc are now useless as they're basically irange_val*. I didn't rename them yet to avoid churn. I'll do it in a later patch. gcc/ChangeLog: * gimple-range-fold.cc (adjust_pointer_diff_expr): Rewrite with irange_val*. (vrp_val_max): New. (vrp_val_min): New. * gimple-range-op.cc (cfn_strlen::fold_range): Use irange_val_*. * range-op.cc (max_limit): Same. (min_limit): Same. (plus_minus_ranges): Same. (operator_rshift::op1_range): Same. (operator_cast::inside_domain_p): Same. * value-range.cc (vrp_val_is_max): Delete. (vrp_val_is_min): Delete. (range_tests_misc): Use irange_val_*. * value-range.h (vrp_val_is_min): Delete. (vrp_val_is_max): Delete. (vrp_val_max): Delete. (irange_val_min): New. (vrp_val_min): Delete. (irange_val_max): New. * vr-values.cc (check_for_binary_op_overflow): Use irange_val_*. --- gcc/gimple-range-fold.cc | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'gcc/gimple-range-fold.cc') diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 62875a3..1b76e6e 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -360,10 +360,10 @@ adjust_pointer_diff_expr (irange &res, const gimple *diff_stmt) && vrp_operand_equal_p (op1, gimple_call_arg (call, 0)) && integer_zerop (gimple_call_arg (call, 1))) { - tree max = vrp_val_max (ptrdiff_type_node); - unsigned prec = TYPE_PRECISION (TREE_TYPE (max)); - wide_int wmaxm1 = wi::to_wide (max, prec) - 1; - res.intersect (int_range<2> (TREE_TYPE (max), wi::zero (prec), wmaxm1)); + wide_int maxm1 = irange_val_max (ptrdiff_type_node) - 1; + res.intersect (int_range<2> (ptrdiff_type_node, + wi::zero (TYPE_PRECISION (ptrdiff_type_node)), + maxm1)); } } @@ -966,6 +966,38 @@ tree_upper_bound (const vrange &r, tree type) return NULL; } +// Return the maximum value for TYPE. + +static inline tree +vrp_val_max (const_tree type) +{ + if (INTEGRAL_TYPE_P (type) + || POINTER_TYPE_P (type)) + return wide_int_to_tree (const_cast (type), irange_val_max (type)); + if (frange::supports_p (type)) + { + REAL_VALUE_TYPE r = frange_val_max (type); + return build_real (const_cast (type), r); + } + return NULL_TREE; +} + +// Return the minimum value for TYPE. + +static inline tree +vrp_val_min (const_tree type) +{ + if (INTEGRAL_TYPE_P (type) + || POINTER_TYPE_P (type)) + return wide_int_to_tree (const_cast (type), irange_val_min (type)); + if (frange::supports_p (type)) + { + REAL_VALUE_TYPE r = frange_val_min (type); + return build_real (const_cast (type), r); + } + return NULL_TREE; +} + // If SCEV has any information about phi node NAME, return it as a range in R. void -- cgit v1.1