From 178abecaa9ca96acee6e155261d4dc50dd98fab4 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Thu, 2 Mar 2023 23:37:20 +0100 Subject: Cleanup irange::set. Now that anti-ranges are no more and iranges contain wide_ints instead of trees, various cleanups are possible. This is one of a handful of patches improving the performance of irange::set() which is not on a hot path, but quite sensitive because it is so pervasive. gcc/ChangeLog: * gimple-range-op.cc (cfn_ffs::fold_range): Use the correct precision. * gimple-ssa-warn-alloca.cc (alloca_call_type): Use <2> for invalid_range, as it is an inverse range. * tree-vrp.cc (find_case_label_range): Avoid trees. * value-range.cc (irange::irange_set): Delete. (irange::irange_set_1bit_anti_range): Delete. (irange::irange_set_anti_range): Delete. (irange::set): Cleanup. * value-range.h (class irange): Remove irange_set, irange_set_anti_range, irange_set_1bit_anti_range. (irange::set_undefined): Remove set to m_type. --- gcc/tree-vrp.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc/tree-vrp.cc') diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc index d28637b..0761b68 100644 --- a/gcc/tree-vrp.cc +++ b/gcc/tree-vrp.cc @@ -827,6 +827,8 @@ find_case_label_range (gswitch *switch_stmt, const irange *range_of_op) size_t i, j; tree op = gimple_switch_index (switch_stmt); tree type = TREE_TYPE (op); + unsigned prec = TYPE_PRECISION (type); + signop sign = TYPE_SIGN (type); tree tmin = wide_int_to_tree (type, range_of_op->lower_bound ()); tree tmax = wide_int_to_tree (type, range_of_op->upper_bound ()); find_case_label_range (switch_stmt, tmin, tmax, &i, &j); @@ -837,9 +839,11 @@ find_case_label_range (gswitch *switch_stmt, const irange *range_of_op) tree label = gimple_switch_label (switch_stmt, i); tree case_high = CASE_HIGH (label) ? CASE_HIGH (label) : CASE_LOW (label); + wide_int wlow = wi::to_wide (CASE_LOW (label)); + wide_int whigh = wi::to_wide (case_high); int_range_max label_range (type, - wi::to_wide (CASE_LOW (label)), - wi::to_wide (case_high)); + wide_int::from (wlow, prec, sign), + wide_int::from (whigh, prec, sign)); if (!types_compatible_p (label_range.type (), range_of_op->type ())) range_cast (label_range, range_of_op->type ()); label_range.intersect (*range_of_op); -- cgit v1.1