From b5c7accfb56a7347008f629be4c7344dd849b1b1 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Wed, 31 Mar 2021 19:34:01 +0100 Subject: data-ref: Tighten index-based alias checks [PR99726] create_intersect_range_checks_index tries to create a runtime alias check based on index comparisons. It looks through the access functions for the two DRs to find a SCEV for the loop that is being versioned and converts a DR_STEP-based check into an index-based check. However, there isn't any reliable sign information in the types, so the code expects the value of the IV step (when interpreted as signed) to be negative iff the DR_STEP (when interpreted as signed) is negative. r10-4762 added another assert related to this assumption and the assert fired for the testcase in the PR. The sign of the IV step didn't match the sign of the DR_STEP. I think this is actually showing what was previously a wrong-code bug. The signs didn't match because the DRs contained *two* access function SCEVs for the loop being versioned. It doesn't look like the code is set up to deal with this, since it checks each access function independently and treats it as the sole source of DR_STEP. The patch therefore moves the main condition out of the loop. This also has the advantage of not building a tree for one access function only to throw it away if we find an inner function that makes the comparison invalid. gcc/ PR tree-optimization/99726 * tree-data-ref.c (create_intersect_range_checks_index): Bail out if there is more than one access function SCEV for the loop being versioned. gcc/testsuite/ PR tree-optimization/99726 * gcc.target/i386/pr99726.c: New test. --- gcc/tree-data-ref.c | 245 +++++++++++++++++++++++++++------------------------- 1 file changed, 128 insertions(+), 117 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 124a7be..e6dd5f1 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -2147,8 +2147,8 @@ create_intersect_range_checks_index (class loop *loop, tree *cond_expr, bool waw_or_war_p = (alias_pair.flags & ~(DR_ALIAS_WAR | DR_ALIAS_WAW)) == 0; - unsigned int i; - for (i = 0; i < DR_NUM_DIMENSIONS (dr_a.dr); i++) + int found = -1; + for (unsigned int i = 0; i < DR_NUM_DIMENSIONS (dr_a.dr); i++) { tree access1 = DR_ACCESS_FN (dr_a.dr, i); tree access2 = DR_ACCESS_FN (dr_b.dr, i); @@ -2164,155 +2164,166 @@ create_intersect_range_checks_index (class loop *loop, tree *cond_expr, return false; } - /* The two indices must have the same step. */ - if (!operand_equal_p (CHREC_RIGHT (access1), CHREC_RIGHT (access2), 0)) + if (found >= 0) return false; + found = i; + } - tree idx_step = CHREC_RIGHT (access1); - /* Index must have const step, otherwise DR_STEP won't be constant. */ - gcc_assert (TREE_CODE (idx_step) == INTEGER_CST); - /* Index must evaluate in the same direction as DR. */ - gcc_assert (!neg_step || tree_int_cst_sign_bit (idx_step) == 1); + /* Ought not to happen in practice, since if all accesses are equal then the + alias should be decidable at compile time. */ + if (found < 0) + return false; - tree min1 = CHREC_LEFT (access1); - tree min2 = CHREC_LEFT (access2); - if (!types_compatible_p (TREE_TYPE (min1), TREE_TYPE (min2))) - return false; + /* The two indices must have the same step. */ + tree access1 = DR_ACCESS_FN (dr_a.dr, found); + tree access2 = DR_ACCESS_FN (dr_b.dr, found); + if (!operand_equal_p (CHREC_RIGHT (access1), CHREC_RIGHT (access2), 0)) + return false; - /* Ideally, alias can be checked against loop's control IV, but we - need to prove linear mapping between control IV and reference - index. Although that should be true, we check against (array) - index of data reference. Like segment length, index length is - linear function of the number of iterations with index_step as - the coefficient, i.e, niter_len * idx_step. */ - offset_int abs_idx_step = offset_int::from (wi::to_wide (idx_step), - SIGNED); - if (neg_step) - abs_idx_step = -abs_idx_step; - poly_offset_int idx_len1 = abs_idx_step * niter_len1; - poly_offset_int idx_len2 = abs_idx_step * niter_len2; - poly_offset_int idx_access1 = abs_idx_step * niter_access1; - poly_offset_int idx_access2 = abs_idx_step * niter_access2; + tree idx_step = CHREC_RIGHT (access1); + /* Index must have const step, otherwise DR_STEP won't be constant. */ + gcc_assert (TREE_CODE (idx_step) == INTEGER_CST); + /* Index must evaluate in the same direction as DR. */ + gcc_assert (!neg_step || tree_int_cst_sign_bit (idx_step) == 1); - gcc_assert (known_ge (idx_len1, 0) - && known_ge (idx_len2, 0) - && known_ge (idx_access1, 0) - && known_ge (idx_access2, 0)); + tree min1 = CHREC_LEFT (access1); + tree min2 = CHREC_LEFT (access2); + if (!types_compatible_p (TREE_TYPE (min1), TREE_TYPE (min2))) + return false; - /* Each access has the following pattern, with lengths measured - in units of INDEX: + /* Ideally, alias can be checked against loop's control IV, but we + need to prove linear mapping between control IV and reference + index. Although that should be true, we check against (array) + index of data reference. Like segment length, index length is + linear function of the number of iterations with index_step as + the coefficient, i.e, niter_len * idx_step. */ + offset_int abs_idx_step = offset_int::from (wi::to_wide (idx_step), + SIGNED); + if (neg_step) + abs_idx_step = -abs_idx_step; + poly_offset_int idx_len1 = abs_idx_step * niter_len1; + poly_offset_int idx_len2 = abs_idx_step * niter_len2; + poly_offset_int idx_access1 = abs_idx_step * niter_access1; + poly_offset_int idx_access2 = abs_idx_step * niter_access2; - <-- idx_len --> - <--- A: -ve step ---> - +-----+-------+-----+-------+-----+ - | n-1 | ..... | 0 | ..... | n-1 | - +-----+-------+-----+-------+-----+ - <--- B: +ve step ---> - <-- idx_len --> - | - min + gcc_assert (known_ge (idx_len1, 0) + && known_ge (idx_len2, 0) + && known_ge (idx_access1, 0) + && known_ge (idx_access2, 0)); - where "n" is the number of scalar iterations covered by the segment - and where each access spans idx_access units. + /* Each access has the following pattern, with lengths measured + in units of INDEX: - A is the range of bytes accessed when the step is negative, - B is the range when the step is positive. + <-- idx_len --> + <--- A: -ve step ---> + +-----+-------+-----+-------+-----+ + | n-1 | ..... | 0 | ..... | n-1 | + +-----+-------+-----+-------+-----+ + <--- B: +ve step ---> + <-- idx_len --> + | + min - When checking for general overlap, we need to test whether - the range: + where "n" is the number of scalar iterations covered by the segment + and where each access spans idx_access units. - [min1 + low_offset1, min2 + high_offset1 + idx_access1 - 1] + A is the range of bytes accessed when the step is negative, + B is the range when the step is positive. - overlaps: + When checking for general overlap, we need to test whether + the range: - [min2 + low_offset2, min2 + high_offset2 + idx_access2 - 1] + [min1 + low_offset1, min1 + high_offset1 + idx_access1 - 1] - where: + overlaps: + + [min2 + low_offset2, min2 + high_offset2 + idx_access2 - 1] - low_offsetN = +ve step ? 0 : -idx_lenN; - high_offsetN = +ve step ? idx_lenN : 0; + where: - This is equivalent to testing whether: + low_offsetN = +ve step ? 0 : -idx_lenN; + high_offsetN = +ve step ? idx_lenN : 0; + + This is equivalent to testing whether: - min1 + low_offset1 <= min2 + high_offset2 + idx_access2 - 1 - && min2 + low_offset2 <= min1 + high_offset1 + idx_access1 - 1 + min1 + low_offset1 <= min2 + high_offset2 + idx_access2 - 1 + && min2 + low_offset2 <= min1 + high_offset1 + idx_access1 - 1 - Converting this into a single test, there is an overlap if: + Converting this into a single test, there is an overlap if: - 0 <= min2 - min1 + bias <= limit + 0 <= min2 - min1 + bias <= limit - where bias = high_offset2 + idx_access2 - 1 - low_offset1 - limit = (high_offset1 - low_offset1 + idx_access1 - 1) - + (high_offset2 - low_offset2 + idx_access2 - 1) - i.e. limit = idx_len1 + idx_access1 - 1 + idx_len2 + idx_access2 - 1 + where bias = high_offset2 + idx_access2 - 1 - low_offset1 + limit = (high_offset1 - low_offset1 + idx_access1 - 1) + + (high_offset2 - low_offset2 + idx_access2 - 1) + i.e. limit = idx_len1 + idx_access1 - 1 + idx_len2 + idx_access2 - 1 - Combining the tests requires limit to be computable in an unsigned - form of the index type; if it isn't, we fall back to the usual - pointer-based checks. + Combining the tests requires limit to be computable in an unsigned + form of the index type; if it isn't, we fall back to the usual + pointer-based checks. - We can do better if DR_B is a write and if DR_A and DR_B are - well-ordered in both the original and the new code (see the - comment above the DR_ALIAS_* flags for details). In this case - we know that for each i in [0, n-1], the write performed by - access i of DR_B occurs after access numbers j<=i of DR_A in - both the original and the new code. Any write or anti - dependencies wrt those DR_A accesses are therefore maintained. + We can do better if DR_B is a write and if DR_A and DR_B are + well-ordered in both the original and the new code (see the + comment above the DR_ALIAS_* flags for details). In this case + we know that for each i in [0, n-1], the write performed by + access i of DR_B occurs after access numbers j<=i of DR_A in + both the original and the new code. Any write or anti + dependencies wrt those DR_A accesses are therefore maintained. - We just need to make sure that each individual write in DR_B does not - overlap any higher-indexed access in DR_A; such DR_A accesses happen - after the DR_B access in the original code but happen before it in - the new code. + We just need to make sure that each individual write in DR_B does not + overlap any higher-indexed access in DR_A; such DR_A accesses happen + after the DR_B access in the original code but happen before it in + the new code. - We know the steps for both accesses are equal, so by induction, we - just need to test whether the first write of DR_B overlaps a later - access of DR_A. In other words, we need to move min1 along by - one iteration: + We know the steps for both accesses are equal, so by induction, we + just need to test whether the first write of DR_B overlaps a later + access of DR_A. In other words, we need to move min1 along by + one iteration: - min1' = min1 + idx_step + min1' = min1 + idx_step - and use the ranges: + and use the ranges: - [min1' + low_offset1', min1' + high_offset1' + idx_access1 - 1] + [min1' + low_offset1', min1' + high_offset1' + idx_access1 - 1] - and: + and: - [min2, min2 + idx_access2 - 1] + [min2, min2 + idx_access2 - 1] - where: + where: - low_offset1' = +ve step ? 0 : -(idx_len1 - |idx_step|) - high_offset1' = +ve_step ? idx_len1 - |idx_step| : 0. */ - if (waw_or_war_p) - idx_len1 -= abs_idx_step; + low_offset1' = +ve step ? 0 : -(idx_len1 - |idx_step|) + high_offset1' = +ve_step ? idx_len1 - |idx_step| : 0. */ + if (waw_or_war_p) + idx_len1 -= abs_idx_step; - poly_offset_int limit = idx_len1 + idx_access1 - 1 + idx_access2 - 1; - if (!waw_or_war_p) - limit += idx_len2; + poly_offset_int limit = idx_len1 + idx_access1 - 1 + idx_access2 - 1; + if (!waw_or_war_p) + limit += idx_len2; - tree utype = unsigned_type_for (TREE_TYPE (min1)); - if (!wi::fits_to_tree_p (limit, utype)) - return false; + tree utype = unsigned_type_for (TREE_TYPE (min1)); + if (!wi::fits_to_tree_p (limit, utype)) + return false; - poly_offset_int low_offset1 = neg_step ? -idx_len1 : 0; - poly_offset_int high_offset2 = neg_step || waw_or_war_p ? 0 : idx_len2; - poly_offset_int bias = high_offset2 + idx_access2 - 1 - low_offset1; - /* Equivalent to adding IDX_STEP to MIN1. */ - if (waw_or_war_p) - bias -= wi::to_offset (idx_step); - - tree subject = fold_build2 (MINUS_EXPR, utype, - fold_convert (utype, min2), - fold_convert (utype, min1)); - subject = fold_build2 (PLUS_EXPR, utype, subject, - wide_int_to_tree (utype, bias)); - tree part_cond_expr = fold_build2 (GT_EXPR, boolean_type_node, subject, - wide_int_to_tree (utype, limit)); - if (*cond_expr) - *cond_expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, - *cond_expr, part_cond_expr); - else - *cond_expr = part_cond_expr; - } + poly_offset_int low_offset1 = neg_step ? -idx_len1 : 0; + poly_offset_int high_offset2 = neg_step || waw_or_war_p ? 0 : idx_len2; + poly_offset_int bias = high_offset2 + idx_access2 - 1 - low_offset1; + /* Equivalent to adding IDX_STEP to MIN1. */ + if (waw_or_war_p) + bias -= wi::to_offset (idx_step); + + tree subject = fold_build2 (MINUS_EXPR, utype, + fold_convert (utype, min2), + fold_convert (utype, min1)); + subject = fold_build2 (PLUS_EXPR, utype, subject, + wide_int_to_tree (utype, bias)); + tree part_cond_expr = fold_build2 (GT_EXPR, boolean_type_node, subject, + wide_int_to_tree (utype, limit)); + if (*cond_expr) + *cond_expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, + *cond_expr, part_cond_expr); + else + *cond_expr = part_cond_expr; if (dump_enabled_p ()) { if (waw_or_war_p) -- 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-data-ref.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index e6dd5f1..09d4667 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -1035,14 +1035,23 @@ split_constant_offset (tree exp, tree *var, tree *off, value_range *exp_range, *exp_range = type; if (code == SSA_NAME) { - wide_int var_min, var_max; - value_range_kind vr_kind = get_range_info (exp, &var_min, &var_max); + value_range vr; + get_range_query (cfun)->range_of_expr (vr, exp); + if (vr.undefined_p ()) + vr.set_varying (TREE_TYPE (exp)); + wide_int var_min = wi::to_wide (vr.min ()); + wide_int var_max = wi::to_wide (vr.max ()); + value_range_kind vr_kind = vr.kind (); wide_int var_nonzero = get_nonzero_bits (exp); vr_kind = intersect_range_with_nonzero_bits (vr_kind, &var_min, &var_max, var_nonzero, TYPE_SIGN (type)); - if (vr_kind == VR_RANGE) + /* This check for VR_VARYING is here because the old code + using get_range_info would return VR_RANGE for the entire + domain, instead of VR_VARYING. The new code normalizes + full-domain ranges to VR_VARYING. */ + if (vr_kind == VR_RANGE || vr_kind == VR_VARYING) *exp_range = value_range (type, var_min, var_max); } } @@ -6298,12 +6307,19 @@ dr_step_indicator (struct data_reference *dr, int useful_min) /* Get the range of values that the unconverted step actually has. */ wide_int step_min, step_max; + value_range vr; if (TREE_CODE (step) != SSA_NAME - || get_range_info (step, &step_min, &step_max) != VR_RANGE) + || !get_range_query (cfun)->range_of_expr (vr, step) + || vr.kind () != VR_RANGE) { step_min = wi::to_wide (TYPE_MIN_VALUE (type)); step_max = wi::to_wide (TYPE_MAX_VALUE (type)); } + else + { + step_min = vr.lower_bound (); + step_max = vr.upper_bound (); + } /* Check whether the unconverted step has an acceptable range. */ signop sgn = TYPE_SIGN (type); -- cgit v1.1 From 04affb328c6a7e29427287c5192da38864f0dbca Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Wed, 26 May 2021 08:53:07 +0200 Subject: Replace uses of determine_value_range with range_of_expr. The expression evaluator changes to the range_query API provide everything determine_value_range does. This patch replaces all uses with calls into the range_query API. gcc/ChangeLog: * calls.c (get_size_range): Use range_of_expr instead of determine_value_range. * tree-affine.c (expr_to_aff_combination): Same. * tree-data-ref.c (split_constant_offset): Same. * tree-vrp.c (determine_value_range_1): Remove. (determine_value_range): Remove. * tree-vrp.h (determine_value_range): Remove. --- gcc/tree-data-ref.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 09d4667..b1f6468 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -1069,12 +1069,12 @@ split_constant_offset (tree exp, tree *var, tree *off, value_range *exp_range, if (INTEGRAL_TYPE_P (type)) *var = fold_convert (sizetype, *var); *off = ssize_int (0); - if (exp_range && code != SSA_NAME) - { - wide_int var_min, var_max; - if (determine_value_range (exp, &var_min, &var_max) == VR_RANGE) - *exp_range = value_range (type, var_min, var_max); - } + + value_range r; + if (exp_range && code != SSA_NAME + && get_range_query (cfun)->range_of_expr (r, exp) + && !r.undefined_p ()) + *exp_range = r; } /* Expresses EXP as VAR + OFF, where OFF is a constant. VAR has the same -- cgit v1.1 From 336c41dbcb21740f8964021e157bc69ca547059b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 11 Jun 2021 09:33:58 +0200 Subject: middle-end/101009 - fix distance vector recording This fixes recording of distance vectors in case the DDR has just constant equal indexes. In that case we expect distance vectors with zero distances to be recorded which is what was done when any distance was computed for affine indexes. 2021-06-11 Richard Biener PR middle-end/101009 * tree-data-ref.c (build_classic_dist_vector_1): Make sure to set *init_b to true when we encounter a constant equal index pair. (compute_affine_dependence): Also dump the actual DR_REF. * gcc.dg/torture/pr101009.c: New testcase. --- gcc/tree-data-ref.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index b1f6468..b37c234 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -5121,6 +5121,8 @@ build_classic_dist_vector_1 (struct data_dependence_relation *ddr, non_affine_dependence_relation (ddr); return false; } + else + *init_b = true; } return true; @@ -5616,9 +5618,13 @@ compute_affine_dependence (struct data_dependence_relation *ddr, if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "(compute_affine_dependence\n"); - fprintf (dump_file, " stmt_a: "); + fprintf (dump_file, " ref_a: "); + print_generic_expr (dump_file, DR_REF (dra)); + fprintf (dump_file, ", stmt_a: "); print_gimple_stmt (dump_file, DR_STMT (dra), 0, TDF_SLIM); - fprintf (dump_file, " stmt_b: "); + fprintf (dump_file, " ref_b: "); + print_generic_expr (dump_file, DR_REF (drb)); + fprintf (dump_file, ", stmt_b: "); print_gimple_stmt (dump_file, DR_STMT (drb), 0, TDF_SLIM); } -- cgit v1.1 From 3f207ab314c071c6060c7c9a429fcf29fd87b594 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Fri, 11 Jun 2021 23:49:22 -0400 Subject: use range based for loops to iterate over vec<> This changes users of FOR_EACH_VEC_ELT to use range based for loops, where the index variables are otherwise unused. As such the index variables are all deleted, producing shorter and simpler code. Signed-off-by: Trevor Saunders gcc/analyzer/ChangeLog: * call-string.cc (call_string::call_string): Use range based for to iterate over vec<>. (call_string::to_json): Likewise. (call_string::hash): Likewise. (call_string::calc_recursion_depth): Likewise. * checker-path.cc (checker_path::fixup_locations): Likewise. * constraint-manager.cc (equiv_class::equiv_class): Likewise. (equiv_class::to_json): Likewise. (equiv_class::hash): Likewise. (constraint_manager::to_json): Likewise. * engine.cc (impl_region_model_context::on_svalue_leak): Likewise. (on_liveness_change): Likewise. (impl_region_model_context::on_unknown_change): Likewise. * program-state.cc (sm_state_map::set_state): Likewise. * region-model.cc (test_canonicalization_4): Likewise. gcc/ChangeLog: * attribs.c (find_attribute_namespace): Iterate over vec<> with range based for. * auto-profile.c (afdo_find_equiv_class): Likewise. * gcc.c (do_specs_vec): Likewise. (do_spec_1): Likewise. (driver::set_up_specs): Likewise. * gimple-loop-jam.c (any_access_function_variant_p): Likewise. * gimple-ssa-store-merging.c (compatible_load_p): Likewise. (imm_store_chain_info::try_coalesce_bswap): Likewise. (imm_store_chain_info::coalesce_immediate_stores): Likewise. (get_location_for_stmts): Likewise. * graphite-poly.c (print_iteration_domains): Likewise. (free_poly_bb): Likewise. (remove_gbbs_in_scop): Likewise. (free_scop): Likewise. (dump_gbb_cases): Likewise. (dump_gbb_conditions): Likewise. (print_pdrs): Likewise. (print_scop): Likewise. * ifcvt.c (cond_move_process_if_block): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * sanopt.c (sanitize_rewrite_addressable_params): Likewise. * sel-sched-dump.c (dump_insn_vector): Likewise. * store-motion.c (store_ops_ok): Likewise. (store_killed_in_insn): Likewise. * timevar.c (timer::named_items::print): Likewise. * tree-cfgcleanup.c (cleanup_control_flow_pre): Likewise. (cleanup_tree_cfg_noloop): Likewise. * tree-data-ref.c (dump_data_references): Likewise. (print_dir_vectors): Likewise. (print_dist_vectors): Likewise. (dump_data_dependence_relations): Likewise. (dump_dist_dir_vectors): Likewise. (dump_ddrs): Likewise. (create_runtime_alias_checks): Likewise. (free_subscripts): Likewise. (save_dist_v): Likewise. (save_dir_v): Likewise. (invariant_access_functions): Likewise. (same_access_functions): Likewise. (access_functions_are_affine_or_constant_p): Likewise. (find_data_references_in_stmt): Likewise. (graphite_find_data_references_in_stmt): Likewise. (free_dependence_relations): Likewise. (free_data_refs): Likewise. * tree-inline.c (copy_debug_stmts): Likewise. * tree-into-ssa.c (dump_currdefs): Likewise. (rewrite_update_phi_arguments): Likewise. * tree-ssa-propagate.c (clean_up_loop_closed_phi): Likewise. * tree-vect-data-refs.c (vect_analyze_possibly_independent_ddr): Likewise. (vect_slp_analyze_node_dependences): Likewise. (vect_slp_analyze_instance_dependence): Likewise. (vect_record_base_alignments): Likewise. (vect_get_peeling_costs_all_drs): Likewise. (vect_peeling_supportable): Likewise. * tree-vectorizer.c (vec_info::~vec_info): Likewise. (vec_info::free_stmt_vec_infos): Likewise. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_call_expression): Iterate over vec<> with range based for. (cxx_eval_store_expression): Likewise. (cxx_eval_loop_expr): Likewise. * decl.c (wrapup_namespace_globals): Likewise. (cp_finish_decl): Likewise. (cxx_simulate_enum_decl): Likewise. * parser.c (cp_parser_postfix_expression): Likewise. --- gcc/tree-data-ref.c | 103 ++++++++++++++-------------------------------------- 1 file changed, 27 insertions(+), 76 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index b37c234..6f3352f 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -170,10 +170,7 @@ ref_contains_union_access_p (tree ref) static void dump_data_references (FILE *file, vec datarefs) { - unsigned int i; - struct data_reference *dr; - - FOR_EACH_VEC_ELT (datarefs, i, dr) + for (data_reference *dr : datarefs) dump_data_reference (file, dr); } @@ -378,10 +375,7 @@ DEBUG_FUNCTION void print_dir_vectors (FILE *outf, vec dir_vects, int length) { - unsigned j; - lambda_vector v; - - FOR_EACH_VEC_ELT (dir_vects, j, v) + for (lambda_vector v : dir_vects) print_direction_vector (outf, v, length); } @@ -403,10 +397,7 @@ DEBUG_FUNCTION void print_dist_vectors (FILE *outf, vec dist_vects, int length) { - unsigned j; - lambda_vector v; - - FOR_EACH_VEC_ELT (dist_vects, j, v) + for (lambda_vector v : dist_vects) print_lambda_vector (outf, v, length); } @@ -499,10 +490,7 @@ DEBUG_FUNCTION void dump_data_dependence_relations (FILE *file, vec ddrs) { - unsigned int i; - struct data_dependence_relation *ddr; - - FOR_EACH_VEC_ELT (ddrs, i, ddr) + for (data_dependence_relation *ddr : ddrs) dump_data_dependence_relation (file, ddr); } @@ -538,21 +526,17 @@ debug_data_dependence_relations (vec ddrs) DEBUG_FUNCTION void dump_dist_dir_vectors (FILE *file, vec ddrs) { - unsigned int i, j; - struct data_dependence_relation *ddr; - lambda_vector v; - - FOR_EACH_VEC_ELT (ddrs, i, ddr) + for (data_dependence_relation *ddr : ddrs) if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE && DDR_AFFINE_P (ddr)) { - FOR_EACH_VEC_ELT (DDR_DIST_VECTS (ddr), j, v) + for (lambda_vector v : DDR_DIST_VECTS (ddr)) { fprintf (file, "DISTANCE_V ("); print_lambda_vector (file, v, DDR_NB_LOOPS (ddr)); fprintf (file, ")\n"); } - FOR_EACH_VEC_ELT (DDR_DIR_VECTS (ddr), j, v) + for (lambda_vector v : DDR_DIR_VECTS (ddr)) { fprintf (file, "DIRECTION_V ("); print_direction_vector (file, v, DDR_NB_LOOPS (ddr)); @@ -568,10 +552,7 @@ dump_dist_dir_vectors (FILE *file, vec ddrs) DEBUG_FUNCTION void dump_ddrs (FILE *file, vec ddrs) { - unsigned int i; - struct data_dependence_relation *ddr; - - FOR_EACH_VEC_ELT (ddrs, i, ddr) + for (data_dependence_relation *ddr : ddrs) dump_data_dependence_relation (file, ddr); fprintf (file, "\n\n"); @@ -2668,19 +2649,17 @@ create_runtime_alias_checks (class loop *loop, tree part_cond_expr; fold_defer_overflow_warnings (); - dr_with_seg_len_pair_t *alias_pair; - unsigned int i; - FOR_EACH_VEC_ELT (*alias_pairs, i, alias_pair) + for (const dr_with_seg_len_pair_t &alias_pair : alias_pairs) { - gcc_assert (alias_pair->flags); + gcc_assert (alias_pair.flags); if (dump_enabled_p ()) dump_printf (MSG_NOTE, "create runtime check for data references %T and %T\n", - DR_REF (alias_pair->first.dr), - DR_REF (alias_pair->second.dr)); + DR_REF (alias_pair.first.dr), + DR_REF (alias_pair.second.dr)); /* Create condition expression for each pair data references. */ - create_intersect_range_checks (loop, &part_cond_expr, *alias_pair); + create_intersect_range_checks (loop, &part_cond_expr, alias_pair); if (*cond_expr) *cond_expr = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, *cond_expr, part_cond_expr); @@ -3436,10 +3415,7 @@ free_conflict_function (conflict_function *f) static void free_subscripts (vec subscripts) { - unsigned i; - subscript_p s; - - FOR_EACH_VEC_ELT (subscripts, i, s) + for (subscript_p s : subscripts) { free_conflict_function (s->conflicting_iterations_in_a); free_conflict_function (s->conflicting_iterations_in_b); @@ -4980,10 +4956,7 @@ analyze_overlapping_iterations (tree chrec_a, static void save_dist_v (struct data_dependence_relation *ddr, lambda_vector dist_v) { - unsigned i; - lambda_vector v; - - FOR_EACH_VEC_ELT (DDR_DIST_VECTS (ddr), i, v) + for (lambda_vector v : DDR_DIST_VECTS (ddr)) if (lambda_vector_equal (v, dist_v, DDR_NB_LOOPS (ddr))) return; @@ -4995,10 +4968,7 @@ save_dist_v (struct data_dependence_relation *ddr, lambda_vector dist_v) static void save_dir_v (struct data_dependence_relation *ddr, lambda_vector dir_v) { - unsigned i; - lambda_vector v; - - FOR_EACH_VEC_ELT (DDR_DIR_VECTS (ddr), i, v) + for (lambda_vector v : DDR_DIR_VECTS (ddr)) if (lambda_vector_equal (v, dir_v, DDR_NB_LOOPS (ddr))) return; @@ -5135,10 +5105,7 @@ static bool invariant_access_functions (const struct data_dependence_relation *ddr, int lnum) { - unsigned i; - subscript *sub; - - FOR_EACH_VEC_ELT (DDR_SUBSCRIPTS (ddr), i, sub) + for (subscript *sub : DDR_SUBSCRIPTS (ddr)) if (!evolution_function_is_invariant_p (SUB_ACCESS_FN (sub, 0), lnum) || !evolution_function_is_invariant_p (SUB_ACCESS_FN (sub, 1), lnum)) return false; @@ -5307,10 +5274,7 @@ add_distance_for_zero_overlaps (struct data_dependence_relation *ddr) static inline bool same_access_functions (const struct data_dependence_relation *ddr) { - unsigned i; - subscript *sub; - - FOR_EACH_VEC_ELT (DDR_SUBSCRIPTS (ddr), i, sub) + for (subscript *sub : DDR_SUBSCRIPTS (ddr)) if (!eq_evolutions_p (SUB_ACCESS_FN (sub, 0), SUB_ACCESS_FN (sub, 1))) return false; @@ -5587,11 +5551,8 @@ static bool access_functions_are_affine_or_constant_p (const struct data_reference *a, const class loop *loop_nest) { - unsigned int i; vec fns = DR_ACCESS_FNS (a); - tree t; - - FOR_EACH_VEC_ELT (fns, i, t) + for (tree t : fns) if (!evolution_function_is_invariant_p (t, loop_nest->num) && !evolution_function_is_affine_multivariate_p (t, loop_nest->num)) return false; @@ -5902,20 +5863,18 @@ opt_result find_data_references_in_stmt (class loop *nest, gimple *stmt, vec *datarefs) { - unsigned i; auto_vec references; - data_ref_loc *ref; data_reference_p dr; if (get_references_in_stmt (stmt, &references)) return opt_result::failure_at (stmt, "statement clobbers memory: %G", stmt); - FOR_EACH_VEC_ELT (references, i, ref) + for (const data_ref_loc &ref : references) { dr = create_data_ref (nest ? loop_preheader_edge (nest) : NULL, - loop_containing_stmt (stmt), ref->ref, - stmt, ref->is_read, ref->is_conditional_in_stmt); + loop_containing_stmt (stmt), ref.ref, + stmt, ref.is_read, ref.is_conditional_in_stmt); gcc_assert (dr != NULL); datarefs->safe_push (dr); } @@ -5933,19 +5892,17 @@ bool graphite_find_data_references_in_stmt (edge nest, loop_p loop, gimple *stmt, vec *datarefs) { - unsigned i; auto_vec references; - data_ref_loc *ref; bool ret = true; data_reference_p dr; if (get_references_in_stmt (stmt, &references)) return false; - FOR_EACH_VEC_ELT (references, i, ref) + for (const data_ref_loc &ref : references) { - dr = create_data_ref (nest, loop, ref->ref, stmt, ref->is_read, - ref->is_conditional_in_stmt); + dr = create_data_ref (nest, loop, ref.ref, stmt, ref.is_read, + ref.is_conditional_in_stmt); gcc_assert (dr != NULL); datarefs->safe_push (dr); } @@ -6253,10 +6210,7 @@ free_dependence_relation (struct data_dependence_relation *ddr) void free_dependence_relations (vec dependence_relations) { - unsigned int i; - struct data_dependence_relation *ddr; - - FOR_EACH_VEC_ELT (dependence_relations, i, ddr) + for (data_dependence_relation *ddr : dependence_relations) if (ddr) free_dependence_relation (ddr); @@ -6268,10 +6222,7 @@ free_dependence_relations (vec dependence_relations) void free_data_refs (vec datarefs) { - unsigned int i; - struct data_reference *dr; - - FOR_EACH_VEC_ELT (datarefs, i, dr) + for (data_reference *dr : datarefs) free_data_ref (dr); datarefs.release (); } -- cgit v1.1 From 3aaa69e5f30e1904d7ca2bb711b1cb0c62b6895f Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Thu, 17 Jun 2021 10:19:31 -0400 Subject: Initial value-relation code. This code provides a both an equivalence and relation oracle which can be accessed via a range_query object. This initial code drop includes the oracles and access them, but does not utilize them yet. * Makefile.in (OBJS): Add value-relation.o. * gimple-range.h: Adjust include files. * tree-data-ref.c: Adjust include file order. * value-query.cc (range_query::get_value_range): Default to no oracle. (range_query::query_relation): New. (range_query::query_relation): New. * value-query.h (class range_query): Adjust. * value-relation.cc: New. * value-relation.h: New. --- gcc/tree-data-ref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 6f3352f..b6abd8b 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -97,8 +97,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-eh.h" #include "ssa.h" #include "internal-fn.h" -#include "range-op.h" #include "vr-values.h" +#include "range-op.h" static struct datadep_stats { -- cgit v1.1 From 00dcc88a0ed7bd148ea86d900b6c93574a2e1f26 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Tue, 20 Jul 2021 11:14:19 -0600 Subject: Adjust by-value function vec arguments to by-reference. gcc/c-family/ChangeLog: * c-common.c (c_build_shufflevector): Adjust by-value argument to by-const-reference. * c-common.h (c_build_shufflevector): Same. gcc/c/ChangeLog: * c-tree.h (c_build_function_call_vec): Adjust by-value argument to by-const-reference. * c-typeck.c (c_build_function_call_vec): Same. gcc/ChangeLog: * cfgloop.h (single_likely_exit): Adjust by-value argument to by-const-reference. * cfgloopanal.c (single_likely_exit): Same. * cgraph.h (struct cgraph_node): Same. * cgraphclones.c (cgraph_node::create_virtual_clone): Same. * genautomata.c (merge_states): Same. * genextract.c (VEC_char_to_string): Same. * genmatch.c (dt_node::gen_kids_1): Same. (walk_captures): Adjust by-value argument to by-reference. * gimple-ssa-store-merging.c (check_no_overlap): Adjust by-value argument to by-const-reference. * gimple.c (gimple_build_call_vec): Same. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Adjust by-value argument to by-reference. * gimple.h (gimple_build_call_vec): Adjust by-value argument to by-const-reference. (gimple_build_call_internal_vec): Same. (gimple_build_switch): Same. (sort_case_labels): Same. (preprocess_case_label_vec_for_gimple): Adjust by-value argument to by-reference. * haifa-sched.c (calc_priorities): Adjust by-value argument to by-const-reference. (sched_init_luids): Same. (haifa_init_h_i_d): Same. * ipa-cp.c (ipa_get_indirect_edge_target_1): Same. (adjust_callers_for_value_intersection): Adjust by-value argument to by-reference. (find_more_scalar_values_for_callers_subset): Adjust by-value argument to by-const-reference. (find_more_contexts_for_caller_subset): Same. (find_aggregate_values_for_callers_subset): Same. (copy_useful_known_contexts): Same. * ipa-fnsummary.c (remap_edge_summaries): Same. (remap_freqcounting_predicate): Same. * ipa-inline.c (add_new_edges_to_heap): Adjust by-value argument to by-reference. * ipa-predicate.c (predicate::remap_after_inlining): Adjust by-value argument to by-const-reference. * ipa-predicate.h (predicate::remap_after_inlining): Same. * ipa-prop.c (ipa_find_agg_cst_for_param): Same. * ipa-prop.h (ipa_find_agg_cst_for_param): Same. * ira-build.c (ira_loop_tree_body_rev_postorder): Same. * read-rtl.c (add_overload_instance): Same. * rtl.h (native_decode_rtx): Same. (native_decode_vector_rtx): Same. * sched-int.h (sched_init_luids): Same. (haifa_init_h_i_d): Same. * simplify-rtx.c (native_decode_vector_rtx): Same. (native_decode_rtx): Same. * tree-call-cdce.c (gen_shrink_wrap_conditions): Same. (shrink_wrap_one_built_in_call_with_conds): Same. (shrink_wrap_conditional_dead_built_in_calls): Same. * tree-data-ref.c (create_runtime_alias_checks): Same. (compute_all_dependences): Same. * tree-data-ref.h (compute_all_dependences): Same. (create_runtime_alias_checks): Same. (index_in_loop_nest): Same. * tree-if-conv.c (mask_exists): Same. * tree-loop-distribution.c (class loop_distribution): Same. (loop_distribution::create_rdg_vertices): Same. (dump_rdg_partitions): Same. (debug_rdg_partitions): Same. (partition_contains_all_rw): Same. (loop_distribution::distribute_loop): Same. * tree-parloops.c (oacc_entry_exit_ok_1): Same. (oacc_entry_exit_single_gang): Same. * tree-ssa-loop-im.c (hoist_memory_references): Same. (loop_suitable_for_sm): Same. * tree-ssa-loop-niter.c (bound_index): Same. * tree-ssa-reassoc.c (update_ops): Same. (swap_ops_for_binary_stmt): Same. (rewrite_expr_tree): Same. (rewrite_expr_tree_parallel): Same. * tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Same. * tree-ssa-sccvn.h (ao_ref_init_from_vn_reference): Same. * tree-ssa-structalias.c (process_all_all_constraints): Same. (make_constraints_to): Same. (handle_lhs_call): Same. (find_func_aliases_for_builtin_call): Same. (sort_fieldstack): Same. (check_for_overlaps): Same. * tree-vect-loop-manip.c (vect_create_cond_for_align_checks): Same. (vect_create_cond_for_unequal_addrs): Same. (vect_create_cond_for_lower_bounds): Same. (vect_create_cond_for_alias_checks): Same. * tree-vect-slp-patterns.c (vect_validate_multiplication): Same. * tree-vect-slp.c (vect_analyze_slp_instance): Same. (vect_make_slp_decision): Same. (vect_slp_bbs): Same. (duplicate_and_interleave): Same. (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. * tree-vectorizer.h (vect_transform_slp_perm_load): Same. (vect_schedule_slp): Same. (duplicate_and_interleave): Same. * tree.c (build_vector_from_ctor): Same. (build_vector): Same. (check_vector_cst): Same. (check_vector_cst_duplicate): Same. (check_vector_cst_fill): Same. (check_vector_cst_stepped): Same. * tree.h (build_vector_from_ctor): Same. --- gcc/tree-data-ref.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index b6abd8b..210ac28 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -2643,7 +2643,7 @@ create_intersect_range_checks (class loop *loop, tree *cond_expr, void create_runtime_alias_checks (class loop *loop, - vec *alias_pairs, + const vec *alias_pairs, tree * cond_expr) { tree part_cond_expr; @@ -5635,9 +5635,9 @@ compute_affine_dependence (struct data_dependence_relation *ddr, is small enough to be handled. */ bool -compute_all_dependences (vec datarefs, +compute_all_dependences (const vec &datarefs, vec *dependence_relations, - vec loop_nest, + const vec &loop_nest, bool compute_self_and_rr) { struct data_dependence_relation *ddr; -- cgit v1.1 From 2d9588bac5ac9e2ed778f3c7eae9ebf7bf258b44 Mon Sep 17 00:00:00 2001 From: Kewen Lin Date: Wed, 21 Jul 2021 00:22:05 -0500 Subject: predcom: Refactor more using auto_vec This patch follows Martin's suggestion at the link[1] to do more refactorings by: - Adding m_ prefix for class pcom_worker member variables. - Using auto_vec instead of vec among class pcom_worker, chain, component and comp_ptrs. The changes in tree-data-ref.[ch] is required, without it the destruction of auto_vec instance could try to double free the memory pointed by m_vec. Bootstrapped and regtested on powerpc64le-linux-gnu P9, x86_64-redhat-linux and aarch64-linux-gnu, also bootstrapped on ppc64le P9 with bootstrap-O3 config. [1] https://gcc.gnu.org/pipermail/gcc-patches/2021-June/573424.html gcc/ChangeLog: * tree-data-ref.c (free_dependence_relations): Adjust to pass vec by reference. (free_data_refs): Likewise. * tree-data-ref.h (free_dependence_relations): Likewise. (free_data_refs): Likewise. * tree-predcom.c (struct chain): Use auto_vec instead of vec for members. (struct component): Likewise. (pcom_worker::pcom_worker): Adjust for auto_vec and renaming changes. (pcom_worker::~pcom_worker): Likewise. (pcom_worker::release_chain): Adjust as auto_vec changes. (pcom_worker::loop): Rename to ... (pcom_worker::m_loop): ... this. (pcom_worker::datarefs): Rename to ... (pcom_worker::m_datarefs): ... this. Use auto_vec instead of vec. (pcom_worker::dependences): Rename to ... (pcom_worker::m_dependences): ... this. Use auto_vec instead of vec. (pcom_worker::chains): Rename to ... (pcom_worker::m_chains): ... this. Use auto_vec instead of vec. (pcom_worker::looparound_phis): Rename to ... (pcom_worker::m_looparound_phis): ... this. Use auto_vec instead of vec. (pcom_worker::cache): Rename to ... (pcom_worker::m_cache): ... this. Use auto_vec instead of vec. (pcom_worker::release_chain): Adjust for auto_vec changes. (pcom_worker::release_chains): Adjust for auto_vec and renaming changes. (release_component): Remove. (release_components): Adjust for release_component removal. (component_of): Adjust to use vec. (merge_comps): Likewise. (pcom_worker::aff_combination_dr_offset): Adjust for renaming changes. (pcom_worker::determine_offset): Likewise. (class comp_ptrs): Remove. (pcom_worker::split_data_refs_to_components): Adjust for renaming changes, for comp_ptrs removal with auto_vec. (pcom_worker::suitable_component_p): Adjust for renaming changes. (pcom_worker::filter_suitable_components): Adjust for release_component removal. (pcom_worker::valid_initializer_p): Adjust for renaming changes. (pcom_worker::find_looparound_phi): Likewise. (pcom_worker::add_looparound_copies): Likewise. (pcom_worker::determine_roots_comp): Likewise. (pcom_worker::single_nonlooparound_use): Likewise. (pcom_worker::execute_pred_commoning_chain): Likewise. (pcom_worker::execute_pred_commoning): Likewise. (pcom_worker::try_combine_chains): Likewise. (pcom_worker::prepare_initializers_chain): Likewise. (pcom_worker::prepare_initializers): Likewise. (pcom_worker::prepare_finalizers_chain): Likewise. (pcom_worker::prepare_finalizers): Likewise. (pcom_worker::tree_predictive_commoning_loop): Likewise. --- gcc/tree-data-ref.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 210ac28..b6f7828 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -6208,7 +6208,7 @@ free_dependence_relation (struct data_dependence_relation *ddr) DEPENDENCE_RELATIONS. */ void -free_dependence_relations (vec dependence_relations) +free_dependence_relations (vec& dependence_relations) { for (data_dependence_relation *ddr : dependence_relations) if (ddr) @@ -6220,7 +6220,7 @@ free_dependence_relations (vec dependence_relations) /* Free the memory used by the data references from DATAREFS. */ void -free_data_refs (vec datarefs) +free_data_refs (vec& datarefs) { for (data_reference *dr : datarefs) free_data_ref (dr); -- cgit v1.1 From a3d3e8c362c2d850543eb2e2631128e1efc368f0 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Thu, 5 Aug 2021 19:50:35 -0600 Subject: Adjust by-value function vec arguments to by-reference. gcc/c/ChangeLog: * c-parser.c (c_parser_declaration_or_fndef): Adjust by-value function vec arguments to by-reference. (c_finish_omp_declare_simd): Same. (c_parser_compound_statement_nostart): Same. (c_parser_for_statement): Same. (c_parser_objc_methodprotolist): Same. (c_parser_oacc_routine): Same. (c_parser_omp_for_loop): Same. (c_parser_omp_declare_simd): Same. gcc/ChangeLog: * dominance.c (prune_bbs_to_update_dominators): Adjust by-value vec arguments to by-reference. (iterate_fix_dominators): Same. * dominance.h (iterate_fix_dominators): Same. * ipa-prop.h: Call auto_vec::to_vec_legacy. * tree-data-ref.c (dump_data_dependence_relation): Adjust by-value vec arguments to by-reference. (debug_data_dependence_relation): Same. (dump_data_dependence_relations): Same. * tree-data-ref.h (debug_data_dependence_relation): Same. (dump_data_dependence_relations): Same. * tree-predcom.c (dump_chains): Same. (initialize_root_vars_lm): Same. (determine_unroll_factor): Same. (replace_phis_by_defined_names): Same. (insert_init_seqs): Same. (pcom_worker::tree_predictive_commoning_loop): Call auto_vec::to_vec_legacy. * tree-ssa-pre.c (insert_into_preds_of_block): Adjust by-value vec arguments to by-reference. * tree-ssa-threadbackward.c (populate_worklist): Same. (back_threader::resolve_def): Same. * tree-vect-data-refs.c (vect_check_nonzero_value): Same. (vect_enhance_data_refs_alignment): Same. (vect_check_lower_bound): Same. (vect_prune_runtime_alias_test_list): Same. (vect_permute_store_chain): Same. * tree-vect-slp-patterns.c (vect_normalize_conj_loc): Same. * tree-vect-stmts.c (vect_create_vectorized_demotion_stmts): Same. * tree-vectorizer.h (vect_permute_store_chain): Same. * vec.c (test_init): New function. (vec_c_tests): Call new function. * vec.h (vec): Declare ctors, dtor, and assignment. (auto_vec::vec_to_legacy): New function. (vec::copy): Adjust initialization. --- gcc/tree-data-ref.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'gcc/tree-data-ref.c') diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index b6f7828..e061baa 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -404,8 +404,7 @@ print_dist_vectors (FILE *outf, vec dist_vects, /* Dump function for a DATA_DEPENDENCE_RELATION structure. */ DEBUG_FUNCTION void -dump_data_dependence_relation (FILE *outf, - struct data_dependence_relation *ddr) +dump_data_dependence_relation (FILE *outf, const data_dependence_relation *ddr) { struct data_reference *dra, *drb; @@ -479,7 +478,7 @@ dump_data_dependence_relation (FILE *outf, /* Debug version. */ DEBUG_FUNCTION void -debug_data_dependence_relation (struct data_dependence_relation *ddr) +debug_data_dependence_relation (const struct data_dependence_relation *ddr) { dump_data_dependence_relation (stderr, ddr); } @@ -487,10 +486,9 @@ debug_data_dependence_relation (struct data_dependence_relation *ddr) /* Dump into FILE all the dependence relations from DDRS. */ DEBUG_FUNCTION void -dump_data_dependence_relations (FILE *file, - vec ddrs) +dump_data_dependence_relations (FILE *file, const vec &ddrs) { - for (data_dependence_relation *ddr : ddrs) + for (auto ddr : ddrs) dump_data_dependence_relation (file, ddr); } -- cgit v1.1