From 2e6ad1ba532fe684633edac766c598be19ad3b59 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 19 May 2021 10:20:37 +0200 Subject: Enable more WITH_SIZE_EXPR processing This enables the alias machinery for WITH_SIZE_EXPR which can appear in call LHS and arguments. In particular this drops the NULL return from get_base_address and it adjusts get_ref_base_and_extent and friends to use the size information in WITH_SIZE_EXPR and look through it for further processing. 2021-05-19 Richard Biener * builtins.c (get_object_alignment_1): Strip outer WITH_SIZE_EXPR. * tree-dfa.c (get_ref_base_and_extent): Handle outer WITH_SIZE_EXPR for size processing and process the containing ref. * tree-ssa-alias.c (ao_ref_base_alias_set): Strip outer WITH_SIZE_EXPR. (ao_ref_base_alias_ptr_type): Likewise. (refs_may_alias_p_2): Allow WITH_SIZE_EXPR in ref->ref and handle that accordingly, stripping it for the core alias workers. * tree.c (get_base_address): Handle WITH_SIZE_EXPR by looking through it instead of returning NULL. --- gcc/tree-dfa.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/tree-dfa.c') diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index 0482b05..c6c3bd6 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -394,6 +394,11 @@ get_ref_base_and_extent (tree exp, poly_int64_pod *poffset, size_tree = DECL_SIZE (TREE_OPERAND (exp, 1)); else if (TREE_CODE (exp) == BIT_FIELD_REF) size_tree = TREE_OPERAND (exp, 1); + else if (TREE_CODE (exp) == WITH_SIZE_EXPR) + { + size_tree = TREE_OPERAND (exp, 1); + exp = TREE_OPERAND (exp, 0); + } else if (!VOID_TYPE_P (TREE_TYPE (exp))) { machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); -- cgit v1.1 From 45f4e2b01b82c72b3a11ff4ad184d7edcf0e63d4 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Wed, 19 May 2021 18:44:08 +0200 Subject: Convert remaining passes to get_range_query. This patch converts the remaining users of get_range_info and get_ptr_nonnull to the get_range_query API. No effort was made to move passes away from VR_ANTI_RANGE, or any other use of deprecated methods. This was a straight up conversion to the new API, nothing else. gcc/ChangeLog: * builtins.c (check_nul_terminated_array): Convert to get_range_query. (expand_builtin_strnlen): Same. (determine_block_size): Same. * fold-const.c (expr_not_equal_to): Same. * gimple-fold.c (size_must_be_zero_p): Same. * gimple-match-head.c: Include gimple-range.h. * gimple-pretty-print.c (dump_ssaname_info): Convert to get_range_query. * gimple-ssa-warn-restrict.c (builtin_memref::extend_offset_range): Same. * graphite-sese-to-poly.c (add_param_constraints): Same. * internal-fn.c (get_min_precision): Same. * ipa-fnsummary.c (set_switch_stmt_execution_predicate): Same. * ipa-prop.c (ipa_compute_jump_functions_for_edge): Same. * match.pd: Same. * tree-data-ref.c (split_constant_offset): Same. (dr_step_indicator): Same. * tree-dfa.c (get_ref_base_and_extent): Same. * tree-scalar-evolution.c (iv_can_overflow_p): Same. * tree-ssa-loop-niter.c (refine_value_range_using_guard): Same. (determine_value_range): Same. (record_nonwrapping_iv): Same. (infer_loop_bounds_from_signedness): Same. (scev_var_range_cant_overflow): Same. * tree-ssa-phiopt.c (two_value_replacement): Same. * tree-ssa-pre.c (insert_into_preds_of_block): Same. * tree-ssa-reassoc.c (optimize_range_tests_to_bit_test): Same. * tree-ssa-strlen.c (handle_builtin_stxncpy_strncat): Same. (get_range): Same. (dump_strlen_info): Same. (set_strlen_range): Same. (maybe_diag_stxncpy_trunc): Same. (get_len_or_size): Same. (handle_integral_assign): Same. * tree-ssa-structalias.c (find_what_p_points_to): Same. * tree-ssa-uninit.c (find_var_cmp_const): Same. * tree-switch-conversion.c (bit_test_cluster::emit): Same. * tree-vect-patterns.c (vect_get_range_info): Same. (vect_recog_divmod_pattern): Same. * tree-vrp.c (intersect_range_with_nonzero_bits): Same. (register_edge_assert_for_2): Same. (determine_value_range_1): Same. * tree.c (get_range_pos_neg): Same. * vr-values.c (vr_values::get_lattice_entry): Same. (vr_values::update_value_range): Same. (simplify_conversion_using_ranges): Same. --- gcc/tree-dfa.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'gcc/tree-dfa.c') diff --git a/gcc/tree-dfa.c b/gcc/tree-dfa.c index c6c3bd6..1d20de0 100644 --- a/gcc/tree-dfa.c +++ b/gcc/tree-dfa.c @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-iterator.h" #include "gimple-walk.h" #include "tree-dfa.h" +#include "gimple-range.h" /* Build and maintain data flow information for trees. */ @@ -535,14 +536,23 @@ get_ref_base_and_extent (tree exp, poly_int64_pod *poffset, index. */ seen_variable_array_ref = true; - wide_int min, max; + value_range vr; + range_query *query; + if (cfun) + query = get_range_query (cfun); + else + query = get_global_range_query (); + if (TREE_CODE (index) == SSA_NAME && (low_bound = array_ref_low_bound (exp), poly_int_tree_p (low_bound)) && (unit_size = array_ref_element_size (exp), TREE_CODE (unit_size) == INTEGER_CST) - && get_range_info (index, &min, &max) == VR_RANGE) + && query->range_of_expr (vr, index) + && vr.kind () == VR_RANGE) { + wide_int min = vr.lower_bound (); + wide_int max = vr.upper_bound (); poly_offset_int lbound = wi::to_poly_offset (low_bound); /* Try to constrain maxsize with range information. */ offset_int omax -- cgit v1.1