From 1fb2b0f69ee849142b669ba1b82264ce6d0f75f9 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sat, 16 Nov 2019 11:35:08 +0000 Subject: [PATCH] Move canonicalisation of dr_with_seg_len_pair_ts The two users of tree-data-ref's runtime alias checks both canonicalise the order of the dr_with_seg_lens in a pair before passing them to prune_runtime_alias_test_list. It's more convenient for later patches if prune_runtime_alias_test_list does that itself. 2019-11-16 Richard Sandiford gcc/ * tree-data-ref.c (prune_runtime_alias_test_list): Sort the two accesses in each dr_with_seg_len_pair_t before trying to combine separate dr_with_seg_len_pair_ts. * tree-loop-distribution.c (compute_alias_check_pairs): Don't do that here. * tree-vect-data-refs.c (vect_prune_runtime_alias_test_list): Likewise. From-SVN: r278348 --- gcc/ChangeLog | 9 +++++++++ gcc/tree-data-ref.c | 21 ++++++++++++++++++++- gcc/tree-loop-distribution.c | 10 ---------- gcc/tree-vect-data-refs.c | 16 ++++------------ 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a9d587..f75f3cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2019-11-16 Richard Sandiford + * tree-data-ref.c (prune_runtime_alias_test_list): Sort the + two accesses in each dr_with_seg_len_pair_t before trying to + combine separate dr_with_seg_len_pair_ts. + * tree-loop-distribution.c (compute_alias_check_pairs): Don't do + that here. + * tree-vect-data-refs.c (vect_prune_runtime_alias_test_list): Likewise. + +2019-11-16 Richard Sandiford + * config/aarch64/aarch64-sve.md (scatter_store): Extend to... (scatter_store): ...this. diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 191beb9..b31ed42 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -1486,13 +1486,32 @@ void prune_runtime_alias_test_list (vec *alias_pairs, poly_uint64) { + /* Canonicalize each pair so that the base components are ordered wrt + data_ref_compare_tree. This allows the loop below to merge more + cases. */ + unsigned int i; + dr_with_seg_len_pair_t *alias_pair; + FOR_EACH_VEC_ELT (*alias_pairs, i, alias_pair) + { + data_reference_p dr_a = alias_pair->first.dr; + data_reference_p dr_b = alias_pair->second.dr; + int comp_res = data_ref_compare_tree (DR_BASE_ADDRESS (dr_a), + DR_BASE_ADDRESS (dr_b)); + if (comp_res == 0) + comp_res = data_ref_compare_tree (DR_OFFSET (dr_a), DR_OFFSET (dr_b)); + if (comp_res == 0) + comp_res = data_ref_compare_tree (DR_INIT (dr_a), DR_INIT (dr_b)); + if (comp_res > 0) + std::swap (alias_pair->first, alias_pair->second); + } + /* Sort the collected data ref pairs so that we can scan them once to combine all possible aliasing checks. */ alias_pairs->qsort (comp_dr_with_seg_len_pair); /* Scan the sorted dr pairs and check if we can combine alias checks of two neighboring dr pairs. */ - for (size_t i = 1; i < alias_pairs->length (); ++i) + for (i = 1; i < alias_pairs->length (); ++i) { /* Deal with two ddrs (dr_a1, dr_b1) and (dr_a2, dr_b2). */ dr_with_seg_len *dr_a1 = &(*alias_pairs)[i-1].first, diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c index 39e17e2..29f8eab 100644 --- a/gcc/tree-loop-distribution.c +++ b/gcc/tree-loop-distribution.c @@ -2456,12 +2456,6 @@ compute_alias_check_pairs (class loop *loop, vec *alias_ddrs, struct data_reference *dr_a = DDR_A (ddr); struct data_reference *dr_b = DDR_B (ddr); tree seg_length_a, seg_length_b; - int comp_res = data_ref_compare_tree (DR_BASE_ADDRESS (dr_a), - DR_BASE_ADDRESS (dr_b)); - - if (comp_res == 0) - comp_res = data_ref_compare_tree (DR_OFFSET (dr_a), DR_OFFSET (dr_b)); - gcc_assert (comp_res != 0); if (latch_dominated_by_data_ref (loop, dr_a)) seg_length_a = data_ref_segment_size (dr_a, niters_plus_one); @@ -2484,10 +2478,6 @@ compute_alias_check_pairs (class loop *loop, vec *alias_ddrs, (dr_with_seg_len (dr_a, seg_length_a, access_size_a, align_a), dr_with_seg_len (dr_b, seg_length_b, access_size_b, align_b)); - /* Canonicalize pairs by sorting the two DR members. */ - if (comp_res > 0) - std::swap (dr_with_seg_len_pair.first, dr_with_seg_len_pair.second); - comp_alias_pairs->safe_push (dr_with_seg_len_pair); } diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 87973b2..c4d627a 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -3477,7 +3477,6 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo) /* First, we collect all data ref pairs for aliasing checks. */ FOR_EACH_VEC_ELT (may_alias_ddrs, i, ddr) { - int comp_res; poly_uint64 lower_bound; tree segment_length_a, segment_length_b; unsigned HOST_WIDE_INT access_size_a, access_size_b; @@ -3593,14 +3592,11 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo) align_a = vect_vfa_align (dr_info_a); align_b = vect_vfa_align (dr_info_b); - comp_res = data_ref_compare_tree (DR_BASE_ADDRESS (dr_info_a->dr), - DR_BASE_ADDRESS (dr_info_b->dr)); - if (comp_res == 0) - comp_res = data_ref_compare_tree (DR_OFFSET (dr_info_a->dr), - DR_OFFSET (dr_info_b->dr)); - /* See whether the alias is known at compilation time. */ - if (comp_res == 0 + if (operand_equal_p (DR_BASE_ADDRESS (dr_info_a->dr), + DR_BASE_ADDRESS (dr_info_b->dr), 0) + && operand_equal_p (DR_OFFSET (dr_info_a->dr), + DR_OFFSET (dr_info_b->dr), 0) && TREE_CODE (DR_STEP (dr_info_a->dr)) == INTEGER_CST && TREE_CODE (DR_STEP (dr_info_b->dr)) == INTEGER_CST && poly_int_tree_p (segment_length_a) @@ -3639,10 +3635,6 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo) dr_with_seg_len (dr_info_b->dr, segment_length_b, access_size_b, align_b)); - /* Canonicalize pairs by sorting the two DR members. */ - if (comp_res > 0) - std::swap (dr_with_seg_len_pair.first, dr_with_seg_len_pair.second); - comp_alias_ddrs.safe_push (dr_with_seg_len_pair); } -- 2.7.4