Hi,
This is the first patch in the series improving tree loop distribution. It
factors out an
interface checking if runtime alias check is possible in order to resolve data
dependence.
This interface is used in both vectorizer and loop distribution to filter out
data dependence
inappropriate for runtime alias check.
Bootstrap and test at O2/O3 on x86_64 and AArch64. is it OK?
Thanks,
bin
2017-05-31 Bin Cheng <bin.ch...@arm.com>
* tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Factor
out code checking if runtime alias check is possible to below ...
Call the new function.
* tree-data-ref.c (runtime_alias_check_p): ... to new function.
* tree-data-ref.h (runtime_alias_check_p): New decalaration.
From a6ec2cc24aeeebf60d1ca4e5a30981a6f31b9e46 Mon Sep 17 00:00:00 2001
From: amker <amker@amker-laptop.(none)>
Date: Mon, 29 May 2017 21:05:29 +0800
Subject: [PATCH 1/5] runtime-alias-check-interface-20170525.txt
---
gcc/tree-data-ref.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
gcc/tree-data-ref.h | 1 +
gcc/tree-vect-data-refs.c | 42 +++-------------------------------------
3 files changed, 53 insertions(+), 39 deletions(-)
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index d16bc36..ba47302 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -1182,6 +1182,55 @@ data_ref_compare_tree (tree t1, tree t2)
return 0;
}
+/* Return TRUE it's possible to resolve data dependence DDR by runtime alias
+ check. */
+
+bool
+runtime_alias_check_p (ddr_p ddr, struct loop *loop, bool speed_p)
+{
+ if (dump_enabled_p ())
+ {
+ dump_printf (MSG_NOTE, "consider run-time aliasing test between ");
+ dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr)));
+ dump_printf (MSG_NOTE, " and ");
+ dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_B (ddr)));
+ dump_printf (MSG_NOTE, "\n");
+ }
+
+ if (!speed_p)
+ {
+ if (dump_enabled_p ())
+ dump_printf (MSG_MISSED_OPTIMIZATION,
+ "runtime alias check not supported when optimizing "
+ "for size.\n");
+ return false;
+ }
+
+ /* FORNOW: We don't support versioning with outer-loop in either
+ vectorization or loop distribution. */
+ if (loop != NULL && loop->inner != NULL)
+ {
+ if (dump_enabled_p ())
+ dump_printf (MSG_MISSED_OPTIMIZATION,
+ "runtime alias check not supported for outer loop.\n");
+ return false;
+ }
+
+ /* FORNOW: We don't support creating runtime alias tests for non-constant
+ step. */
+ if (TREE_CODE (DR_STEP (DDR_A (ddr))) != INTEGER_CST
+ || TREE_CODE (DR_STEP (DDR_B (ddr))) != INTEGER_CST)
+ {
+ if (dump_enabled_p ())
+ dump_printf (MSG_MISSED_OPTIMIZATION,
+ "runtime alias check not supported for non-constant "
+ "step\n");
+ return false;
+ }
+
+ return true;
+}
+
/* Operator == between two dr_with_seg_len objects.
This equality operator is used to make sure two data refs
diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h
index 1d8e01d..0013049 100644
--- a/gcc/tree-data-ref.h
+++ b/gcc/tree-data-ref.h
@@ -368,6 +368,7 @@ extern bool dr_may_alias_p (const struct data_reference *,
extern bool dr_equal_offsets_p (struct data_reference *,
struct data_reference *);
+extern bool runtime_alias_check_p (ddr_p, struct loop *, bool);
extern int data_ref_compare_tree (tree, tree);
extern void prune_runtime_alias_test_list (vec<dr_with_seg_len_pair_t> *,
unsigned HOST_WIDE_INT);
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 5103ba1..f105f12 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -150,45 +150,9 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_vec_info loop_vinfo)
if ((unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS) == 0)
return false;
- if (dump_enabled_p ())
- {
- dump_printf_loc (MSG_NOTE, vect_location,
- "mark for run-time aliasing test between ");
- dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr)));
- dump_printf (MSG_NOTE, " and ");
- dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_B (ddr)));
- dump_printf (MSG_NOTE, "\n");
- }
-
- if (optimize_loop_nest_for_size_p (loop))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "versioning not supported when optimizing"
- " for size.\n");
- return false;
- }
-
- /* FORNOW: We don't support versioning with outer-loop vectorization. */
- if (loop->inner)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "versioning not yet supported for outer-loops.\n");
- return false;
- }
-
- /* FORNOW: We don't support creating runtime alias tests for non-constant
- step. */
- if (TREE_CODE (DR_STEP (DDR_A (ddr))) != INTEGER_CST
- || TREE_CODE (DR_STEP (DDR_B (ddr))) != INTEGER_CST)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "versioning not yet supported for non-constant "
- "step\n");
- return false;
- }
+ if (!runtime_alias_check_p (ddr, loop,
+ optimize_loop_nest_for_speed_p (loop)))
+ return false;
LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo).safe_push (ddr);
return true;
--
1.9.1