From 6355150f585e2d746a62df19ae89df7c93e8c3c7 Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Wed, 7 Jun 2017 11:28:17 +0000 Subject: [PATCH] tree-vect-data-refs.c (vect_mark_for_runtime_alias_test): Factor out code checking if runtime alias check is possible to below ... * 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-SVN: r248962 --- gcc/ChangeLog | 8 +++++++ gcc/tree-data-ref.c | 49 +++++++++++++++++++++++++++++++++++++++ gcc/tree-data-ref.h | 1 + gcc/tree-vect-data-refs.c | 42 +++------------------------------ 4 files changed, 61 insertions(+), 39 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fa94c6fa46a..e34747f5310 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-06-07 Bin Cheng + + * 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. + 2017-06-07 Marek Polacek PR sanitizer/80932 diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index d16bc361d09..ba473021534 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 1d8e01dd7fe..0013049053f 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 *, unsigned HOST_WIDE_INT); diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index e8e2658e218..623acf695ed 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; -- 2.30.2