aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2018-07-31 14:21:11 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-07-31 14:21:11 +0000
commit0847049dc7a630e4bfa079767ed42c742ff6276b (patch)
treef0f5c51a06ed7cf34ab3931f6a4dbe03b657045a /gcc
parent686dca7612a8ab5ebebad2fc13bd9ea7793a7e40 (diff)
downloadgcc-0847049dc7a630e4bfa079767ed42c742ff6276b.zip
gcc-0847049dc7a630e4bfa079767ed42c742ff6276b.tar.gz
gcc-0847049dc7a630e4bfa079767ed42c742ff6276b.tar.bz2
[01/46] Move special cases out of get_initial_def_for_reduction
This minor clean-up avoids repeating the test for double reductions and also moves the vect_get_vec_def_for_operand call to the same function as the corresponding vect_get_vec_def_for_stmt_copy. 2018-07-31 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-loop.c (get_initial_def_for_reduction): Move special cases for nested loops from here to ... (vect_create_epilog_for_reduction): ...here. Only call vect_is_simple_use for inner-loop reductions. From-SVN: r263116
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-vect-loop.c52
2 files changed, 25 insertions, 34 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ca67815..391cc65 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
+
+ * tree-vect-loop.c (get_initial_def_for_reduction): Move special
+ cases for nested loops from here to ...
+ (vect_create_epilog_for_reduction): ...here. Only call
+ vect_is_simple_use for inner-loop reductions.
+
2018-07-31 Martin Liska <mliska@suse.cz>
PR gcov-profile/85338
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 9b7147c..18fa30b 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -4113,10 +4113,8 @@ get_initial_def_for_reduction (gimple *stmt, tree init_val,
enum tree_code code = gimple_assign_rhs_code (stmt);
tree def_for_init;
tree init_def;
- bool nested_in_vect_loop = false;
REAL_VALUE_TYPE real_init_val = dconst0;
int int_init_val = 0;
- gimple *def_stmt = NULL;
gimple_seq stmts = NULL;
gcc_assert (vectype);
@@ -4124,39 +4122,12 @@ get_initial_def_for_reduction (gimple *stmt, tree init_val,
gcc_assert (POINTER_TYPE_P (scalar_type) || INTEGRAL_TYPE_P (scalar_type)
|| SCALAR_FLOAT_TYPE_P (scalar_type));
- if (nested_in_vect_loop_p (loop, stmt))
- nested_in_vect_loop = true;
- else
- gcc_assert (loop == (gimple_bb (stmt))->loop_father);
-
- /* In case of double reduction we only create a vector variable to be put
- in the reduction phi node. The actual statement creation is done in
- vect_create_epilog_for_reduction. */
- if (adjustment_def && nested_in_vect_loop
- && TREE_CODE (init_val) == SSA_NAME
- && (def_stmt = SSA_NAME_DEF_STMT (init_val))
- && gimple_code (def_stmt) == GIMPLE_PHI
- && flow_bb_inside_loop_p (loop, gimple_bb (def_stmt))
- && vinfo_for_stmt (def_stmt)
- && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (def_stmt))
- == vect_double_reduction_def)
- {
- *adjustment_def = NULL;
- return vect_create_destination_var (init_val, vectype);
- }
+ gcc_assert (nested_in_vect_loop_p (loop, stmt)
+ || loop == (gimple_bb (stmt))->loop_father);
vect_reduction_type reduction_type
= STMT_VINFO_VEC_REDUCTION_TYPE (stmt_vinfo);
- /* In case of a nested reduction do not use an adjustment def as
- that case is not supported by the epilogue generation correctly
- if ncopies is not one. */
- if (adjustment_def && nested_in_vect_loop)
- {
- *adjustment_def = NULL;
- return vect_get_vec_def_for_operand (init_val, stmt);
- }
-
switch (code)
{
case WIDEN_SUM_EXPR:
@@ -4586,9 +4557,22 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, gimple *stmt,
|| (induc_code == MIN_EXPR
&& tree_int_cst_lt (induc_val, initial_def))))
induc_val = initial_def;
- vect_is_simple_use (initial_def, loop_vinfo, &initial_def_dt);
- vec_initial_def = get_initial_def_for_reduction (stmt, initial_def,
- &adjustment_def);
+
+ if (double_reduc)
+ /* In case of double reduction we only create a vector variable
+ to be put in the reduction phi node. The actual statement
+ creation is done later in this function. */
+ vec_initial_def = vect_create_destination_var (initial_def, vectype);
+ else if (nested_in_vect_loop)
+ {
+ /* Do not use an adjustment def as that case is not supported
+ correctly if ncopies is not one. */
+ vect_is_simple_use (initial_def, loop_vinfo, &initial_def_dt);
+ vec_initial_def = vect_get_vec_def_for_operand (initial_def, stmt);
+ }
+ else
+ vec_initial_def = get_initial_def_for_reduction (stmt, initial_def,
+ &adjustment_def);
vec_initial_defs.create (1);
vec_initial_defs.quick_push (vec_initial_def);
}