gcc/gcc/range.h
Aldy Hernandez 6fb43d1b90 Remove value_range typedef.
Now that pointers and integers have been disambiguated from irange,
and all the pointer range temporaries use prange, we can reclaim
value_range as a general purpose range container.

This patch removes the typedef, in favor of int_range_max, thus
providing slightly better ranges in places.  I have also used
int_range<1> or <2> when it's known ahead of time how big the range will
be, thus saving a few words.

In a follow-up patch I will rename the Value_Range temporary to
value_range.

No change in performance.

gcc/ChangeLog:

	* builtins.cc (expand_builtin_strnlen): Replace value_range use
	with int_range_max or irange when appropriate.
	(determine_block_size): Same.
	* fold-const.cc (minmax_from_comparison): Same.
	* gimple-array-bounds.cc (check_out_of_bounds_and_warn): Same.
	(array_bounds_checker::check_array_ref): Same.
	* gimple-fold.cc (size_must_be_zero_p): Same.
	* gimple-predicate-analysis.cc (find_var_cmp_const): Same.
	* gimple-ssa-sprintf.cc (get_int_range): Same.
	(format_integer): Same.
	(try_substitute_return_value): Same.
	(handle_printf_call): Same.
	* gimple-ssa-warn-restrict.cc
	(builtin_memref::extend_offset_range): Same.
	* graphite-sese-to-poly.cc (add_param_constraints): Same.
	* internal-fn.cc (get_min_precision): Same.
	* match.pd: Same.
	* pointer-query.cc (get_size_range): Same.
	* range-op.cc (get_shift_range): Same.
	(operator_trunc_mod::op1_range): Same.
	(operator_trunc_mod::op2_range): Same.
	* range.cc (range_negatives): Same.
	* range.h (range_positives): Same.
	(range_negatives): Same.
	* tree-affine.cc (expr_to_aff_combination): Same.
	* tree-data-ref.cc (compute_distributive_range): Same.
	(nop_conversion_for_offset_p): Same.
	(split_constant_offset): Same.
	(split_constant_offset_1): Same.
	(dr_step_indicator): Same.
	* tree-dfa.cc (get_ref_base_and_extent): Same.
	* tree-scalar-evolution.cc (iv_can_overflow_p): Same.
	* tree-ssa-math-opts.cc (optimize_spaceship): Same.
	* tree-ssa-pre.cc (insert_into_preds_of_block): Same.
	* tree-ssa-reassoc.cc (optimize_range_tests_to_bit_test): Same.
	* tree-ssa-strlen.cc (compare_nonzero_chars): Same.
	(dump_strlen_info): Same.
	(get_range_strlen_dynamic): Same.
	(set_strlen_range): Same.
	(maybe_diag_stxncpy_trunc): Same.
	(strlen_pass::get_len_or_size): Same.
	(strlen_pass::handle_builtin_string_cmp): Same.
	(strlen_pass::count_nonzero_bytes_addr): Same.
	(strlen_pass::handle_integral_assign): Same.
	* tree-switch-conversion.cc (bit_test_cluster::emit): Same.
	* tree-vect-loop-manip.cc (vect_gen_vector_loop_niters): Same.
	(vect_do_peeling): Same.
	* tree-vect-patterns.cc (vect_get_range_info): Same.
	(vect_recog_divmod_pattern): Same.
	* tree.cc (get_range_pos_neg): Same.
	* value-range.cc (debug): Remove value_range variants.
	* value-range.h (value_range): Remove typedef.
	* vr-values.cc
	(simplify_using_ranges::op_with_boolean_value_range_p): Replace
	value_range use with int_range_max or irange when appropriate.
	(check_for_binary_op_overflow): Same.
	(simplify_using_ranges::legacy_fold_cond_overflow): Same.
	(find_case_label_ranges): Same.
	(simplify_using_ranges::simplify_abs_using_ranges): Same.
	(test_for_singularity): Same.
	(simplify_using_ranges::simplify_compare_using_ranges_1): Same.
	(simplify_using_ranges::simplify_casted_compare): Same.
	(simplify_using_ranges::simplify_switch_using_ranges): Same.
	(simplify_conversion_using_ranges): Same.
	(simplify_using_ranges::two_valued_val_range_p): Same.
2024-06-03 14:56:55 +02:00

57 lines
1.6 KiB
C++

/* Header file for misc range functions. -*- C++ -*-
Copyright (C) 2017-2024 Free Software Foundation, Inc.
Contributed by Aldy Hernandez <aldyh@redhat.com>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_RANGE_H
#define GCC_RANGE_H
int_range<2> range_positives (tree type);
int_range<2> range_negatives (tree type);
// Return an irange instance that is a boolean TRUE.
inline int_range<1>
range_true (tree type = boolean_type_node)
{
unsigned prec = TYPE_PRECISION (type);
return int_range<1> (type, wi::one (prec), wi::one (prec));
}
// Return an irange instance that is a boolean FALSE.
inline int_range<1>
range_false (tree type = boolean_type_node)
{
unsigned prec = TYPE_PRECISION (type);
return int_range<1> (type, wi::zero (prec), wi::zero (prec));
}
// Return an irange that covers both true and false.
inline int_range<1>
range_true_and_false (tree type = boolean_type_node)
{
unsigned prec = TYPE_PRECISION (type);
if (prec == 1)
return int_range<1> (type);
return int_range<1> (type, wi::zero (prec), wi::one (prec));
}
#endif // GCC_RANGE_H