From: Frederik Harwath <frederik@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Subject: [OG11][committed][PATCH 07/22] Move compute_alias_check_pairs to tree-data-ref.c
Date: Wed, 17 Nov 2021 17:03:15 +0100 [thread overview]
Message-ID: <20211117160330.20029-7-frederik@codesourcery.com> (raw)
In-Reply-To: <20211117160330.20029-1-frederik@codesourcery.com>
Move this function from tree-loop-distribution.c to tree-data-ref.c
and make it non-static to enable its use from other parts of GCC.
gcc/ChangeLog:
* tree-loop-distribution.c (data_ref_segment_size): Remove function.
(latch_dominated_by_data_ref): Likewise.
(compute_alias_check_pairs): Likewise.
* tree-data-ref.c (data_ref_segment_size): New function,
copied from tree-loop-distribution.c
(compute_alias_check_pairs): Likewise.
(latch_dominated_by_data_ref): Likewise.
* tree-data-ref.h (compute_alias_check_pairs): New declaration.
---
gcc/tree-data-ref.c | 87 ++++++++++++++++++++++++++++++++++++
gcc/tree-data-ref.h | 3 ++
gcc/tree-loop-distribution.c | 87 ------------------------------------
3 files changed, 90 insertions(+), 87 deletions(-)
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index d04e95f7c285..71f8d790e618 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -2645,6 +2645,93 @@ create_intersect_range_checks (class loop *loop, tree *cond_expr,
dump_printf (MSG_NOTE, "using an address-based overlap test\n");
}
+/* Compute and return an expression whose value is the segment length which
+ will be accessed by DR in NITERS iterations. */
+
+static tree
+data_ref_segment_size (struct data_reference *dr, tree niters)
+{
+ niters = size_binop (MINUS_EXPR,
+ fold_convert (sizetype, niters),
+ size_one_node);
+ return size_binop (MULT_EXPR,
+ fold_convert (sizetype, DR_STEP (dr)),
+ fold_convert (sizetype, niters));
+}
+
+/* Return true if LOOP's latch is dominated by statement for data reference
+ DR. */
+
+static inline bool
+latch_dominated_by_data_ref (class loop *loop, data_reference *dr)
+{
+ return dominated_by_p (CDI_DOMINATORS, single_exit (loop)->src,
+ gimple_bb (DR_STMT (dr)));
+}
+
+/* Compute alias check pairs and store them in COMP_ALIAS_PAIRS for LOOP's
+ data dependence relations ALIAS_DDRS. */
+
+void
+compute_alias_check_pairs (class loop *loop, vec<ddr_p> *alias_ddrs,
+ vec<dr_with_seg_len_pair_t> *comp_alias_pairs)
+{
+ unsigned int i;
+ unsigned HOST_WIDE_INT factor = 1;
+ tree niters_plus_one, niters = number_of_latch_executions (loop);
+
+ gcc_assert (niters != NULL_TREE && niters != chrec_dont_know);
+ niters = fold_convert (sizetype, niters);
+ niters_plus_one = size_binop (PLUS_EXPR, niters, size_one_node);
+
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Creating alias check pairs:\n");
+
+ /* Iterate all data dependence relations and compute alias check pairs. */
+ for (i = 0; i < alias_ddrs->length (); i++)
+ {
+ ddr_p ddr = (*alias_ddrs)[i];
+ struct data_reference *dr_a = DDR_A (ddr);
+ struct data_reference *dr_b = DDR_B (ddr);
+ tree seg_length_a, seg_length_b;
+
+ if (latch_dominated_by_data_ref (loop, dr_a))
+ seg_length_a = data_ref_segment_size (dr_a, niters_plus_one);
+ else
+ seg_length_a = data_ref_segment_size (dr_a, niters);
+
+ if (latch_dominated_by_data_ref (loop, dr_b))
+ seg_length_b = data_ref_segment_size (dr_b, niters_plus_one);
+ else
+ seg_length_b = data_ref_segment_size (dr_b, niters);
+
+ unsigned HOST_WIDE_INT access_size_a
+ = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_a))));
+ unsigned HOST_WIDE_INT access_size_b
+ = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_b))));
+ unsigned int align_a = TYPE_ALIGN_UNIT (TREE_TYPE (DR_REF (dr_a)));
+ unsigned int align_b = TYPE_ALIGN_UNIT (TREE_TYPE (DR_REF (dr_b)));
+
+ dr_with_seg_len_pair_t dr_with_seg_len_pair
+ (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),
+ /* ??? Would WELL_ORDERED be safe? */
+ dr_with_seg_len_pair_t::REORDERED);
+
+ comp_alias_pairs->safe_push (dr_with_seg_len_pair);
+ }
+
+ if (tree_fits_uhwi_p (niters))
+ factor = tree_to_uhwi (niters);
+
+ /* Prune alias check pairs. */
+ prune_runtime_alias_test_list (comp_alias_pairs, factor);
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file,
+ "Improved number of alias checks from %d to %d\n",
+ alias_ddrs->length (), comp_alias_pairs->length ());
+}
+
/* Create a conditional expression that represents the run-time checks for
overlapping of address ranges represented by a list of data references
pairs passed in ALIAS_PAIRS. Data references are in LOOP. The returned
diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h
index 8001cc54f518..5016ec926b1d 100644
--- a/gcc/tree-data-ref.h
+++ b/gcc/tree-data-ref.h
@@ -577,6 +577,9 @@ extern opt_result runtime_alias_check_p (ddr_p, class loop *, bool);
extern int data_ref_compare_tree (tree, tree);
extern void prune_runtime_alias_test_list (vec<dr_with_seg_len_pair_t> *,
poly_uint64);
+
+extern void compute_alias_check_pairs (class loop *, vec<ddr_p> *,
+ vec<dr_with_seg_len_pair_t> *);
extern void create_runtime_alias_checks (class loop *,
vec<dr_with_seg_len_pair_t> *, tree*);
extern tree dr_direction_indicator (struct data_reference *);
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 65aa1df4abae..d987cdb34424 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -2559,93 +2559,6 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg,
}
}
-/* Compute and return an expression whose value is the segment length which
- will be accessed by DR in NITERS iterations. */
-
-static tree
-data_ref_segment_size (struct data_reference *dr, tree niters)
-{
- niters = size_binop (MINUS_EXPR,
- fold_convert (sizetype, niters),
- size_one_node);
- return size_binop (MULT_EXPR,
- fold_convert (sizetype, DR_STEP (dr)),
- fold_convert (sizetype, niters));
-}
-
-/* Return true if LOOP's latch is dominated by statement for data reference
- DR. */
-
-static inline bool
-latch_dominated_by_data_ref (class loop *loop, data_reference *dr)
-{
- return dominated_by_p (CDI_DOMINATORS, single_exit (loop)->src,
- gimple_bb (DR_STMT (dr)));
-}
-
-/* Compute alias check pairs and store them in COMP_ALIAS_PAIRS for LOOP's
- data dependence relations ALIAS_DDRS. */
-
-static void
-compute_alias_check_pairs (class loop *loop, vec<ddr_p> *alias_ddrs,
- vec<dr_with_seg_len_pair_t> *comp_alias_pairs)
-{
- unsigned int i;
- unsigned HOST_WIDE_INT factor = 1;
- tree niters_plus_one, niters = number_of_latch_executions (loop);
-
- gcc_assert (niters != NULL_TREE && niters != chrec_dont_know);
- niters = fold_convert (sizetype, niters);
- niters_plus_one = size_binop (PLUS_EXPR, niters, size_one_node);
-
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file, "Creating alias check pairs:\n");
-
- /* Iterate all data dependence relations and compute alias check pairs. */
- for (i = 0; i < alias_ddrs->length (); i++)
- {
- ddr_p ddr = (*alias_ddrs)[i];
- struct data_reference *dr_a = DDR_A (ddr);
- struct data_reference *dr_b = DDR_B (ddr);
- tree seg_length_a, seg_length_b;
-
- if (latch_dominated_by_data_ref (loop, dr_a))
- seg_length_a = data_ref_segment_size (dr_a, niters_plus_one);
- else
- seg_length_a = data_ref_segment_size (dr_a, niters);
-
- if (latch_dominated_by_data_ref (loop, dr_b))
- seg_length_b = data_ref_segment_size (dr_b, niters_plus_one);
- else
- seg_length_b = data_ref_segment_size (dr_b, niters);
-
- unsigned HOST_WIDE_INT access_size_a
- = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_a))));
- unsigned HOST_WIDE_INT access_size_b
- = tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_b))));
- unsigned int align_a = TYPE_ALIGN_UNIT (TREE_TYPE (DR_REF (dr_a)));
- unsigned int align_b = TYPE_ALIGN_UNIT (TREE_TYPE (DR_REF (dr_b)));
-
- dr_with_seg_len_pair_t dr_with_seg_len_pair
- (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),
- /* ??? Would WELL_ORDERED be safe? */
- dr_with_seg_len_pair_t::REORDERED);
-
- comp_alias_pairs->safe_push (dr_with_seg_len_pair);
- }
-
- if (tree_fits_uhwi_p (niters))
- factor = tree_to_uhwi (niters);
-
- /* Prune alias check pairs. */
- prune_runtime_alias_test_list (comp_alias_pairs, factor);
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- "Improved number of alias checks from %d to %d\n",
- alias_ddrs->length (), comp_alias_pairs->length ());
-}
-
/* Given data dependence relations in ALIAS_DDRS, generate runtime alias
checks and version LOOP under condition of these runtime alias checks. */
--
2.33.0
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
next prev parent reply other threads:[~2021-11-17 16:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 16:03 [OG11][committed][PATCH 00/22] OpenACC "kernels" Improvements Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 01/22] Fortran: delinearize multi-dimensional array accesses Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 02/22] openacc: Move pass_oacc_device_lower after pass_graphite Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 03/22] graphite: Extend SCoP detection dump output Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 04/22] graphite: Rename isl_id_for_ssa_name Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 05/22] graphite: Fix minor mistakes in comments Frederik Harwath
2021-11-17 16:03 ` Frederik Harwath [this message]
2021-11-17 16:03 ` [OG11][committed][PATCH 08/22] graphite: Add runtime alias checking Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 09/22] openacc: Use Graphite for dependence analysis in "kernels" regions Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 10/22] openacc: Add "can_be_parallel" flag info to "graph" dumps Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 11/22] openacc: Add further kernels tests Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 12/22] openacc: Remove unused partitioning in "kernels" regions Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 13/22] Add function for printing a single OMP_CLAUSE Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 14/22] openacc: Add data optimization pass Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 15/22] openacc: Add runtime alias checking for OpenACC kernels Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 16/22] openacc: Warn about "independent" "kernels" loops with data-dependences Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 17/22] openacc: Handle internal function calls in pass_lim Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 18/22] openacc: Disable pass_pre on outlined functions analyzed by Graphite Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 19/22] graphite: Tune parameters for OpenACC use Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 20/22] graphite: Adjust scop loop-nest choice Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 21/22] graphite: Accept loops without data references Frederik Harwath
2021-11-17 16:03 ` [OG11][committed][PATCH 22/22] openacc: Adjust test expectations to new "kernels" handling Frederik Harwath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211117160330.20029-7-frederik@codesourcery.com \
--to=frederik@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).