From effb52dae5203e21faf5f2c11bb0078e71f74482 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 22 May 2015 13:52:58 +0000 Subject: [PATCH] tree-vectorizer.h (struct _slp_oprnd_info): Add second_pattern member. 2015-05-22 Richard Biener * tree-vectorizer.h (struct _slp_oprnd_info): Add second_pattern member. * tree-vect-loop.c (vect_analyze_loop_operations): Look at patterns when determining whether SLP is pure. (vect_is_slp_reduction): Remove check for pattern stmts. (vect_is_simple_reduction_1): Remove dead code. * tree-vect-slp.c (vect_create_oprnd_info): Initialize second_pattern. (vect_get_and_check_slp_defs): Pass in the stmt number. Allow the first def in a reduction to be not a pattern stmt when the rest of the stmts def are patterns. (vect_build_slp_tree_1): Allow tcc_expression codes like SAD_EXPR and DOT_PROD_EXPR. (vect_build_slp_tree): Adjust. (vect_analyze_slp): Refactor and move BB vect error message ... (vect_slp_analyze_bb_1): ... here. From-SVN: r223574 --- gcc/ChangeLog | 18 ++++++++++++++++++ gcc/tree-vect-loop.c | 23 ++++++++++------------- gcc/tree-vect-slp.c | 42 +++++++++++++++++++++++------------------- gcc/tree-vectorizer.h | 1 + 4 files changed, 52 insertions(+), 32 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 58abb46c997..212b8e57527 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,21 @@ +2015-05-22 Richard Biener + + * tree-vectorizer.h (struct _slp_oprnd_info): Add second_pattern + member. + * tree-vect-loop.c (vect_analyze_loop_operations): Look at + patterns when determining whether SLP is pure. + (vect_is_slp_reduction): Remove check for pattern stmts. + (vect_is_simple_reduction_1): Remove dead code. + * tree-vect-slp.c (vect_create_oprnd_info): Initialize second_pattern. + (vect_get_and_check_slp_defs): Pass in the stmt number. + Allow the first def in a reduction to be not a pattern stmt when + the rest of the stmts def are patterns. + (vect_build_slp_tree_1): Allow tcc_expression codes like + SAD_EXPR and DOT_PROD_EXPR. + (vect_build_slp_tree): Adjust. + (vect_analyze_slp): Refactor and move BB vect error message ... + (vect_slp_analyze_bb_1): ... here. + 2015-05-22 Aldy Hernandez * tree-switch-conversion.c (build_one_array): Set DECL_IGNORED_P diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 123958b31ca..2c983b889d1 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1399,7 +1399,12 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) { gimple stmt = gsi_stmt (si); stmt_vec_info stmt_info = vinfo_for_stmt (stmt); - gcc_assert (stmt_info); + if (STMT_VINFO_IN_PATTERN_P (stmt_info) + && STMT_VINFO_RELATED_STMT (stmt_info)) + { + stmt = STMT_VINFO_RELATED_STMT (stmt_info); + stmt_info = vinfo_for_stmt (stmt); + } if ((STMT_VINFO_RELEVANT_P (stmt_info) || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info))) && !PURE_SLP_STMT (stmt_info)) @@ -2031,12 +2036,8 @@ vect_is_slp_reduction (loop_vec_info loop_info, gimple phi, gimple first_stmt) if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) { - if (vinfo_for_stmt (use_stmt) - && !STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt))) - { - loop_use_stmt = use_stmt; - nloop_uses++; - } + loop_use_stmt = use_stmt; + nloop_uses++; } else n_out_of_loop_uses++; @@ -2265,9 +2266,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi, return NULL; } - if (vinfo_for_stmt (use_stmt) - && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt))) - nloop_uses++; + nloop_uses++; if (nloop_uses > 1) { if (dump_enabled_p ()) @@ -2325,9 +2324,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi, gimple use_stmt = USE_STMT (use_p); if (is_gimple_debug (use_stmt)) continue; - if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)) - && vinfo_for_stmt (use_stmt) - && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt))) + if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) nloop_uses++; if (nloop_uses > 1) { diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 21489b3ed3a..1c519903153 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -183,6 +183,7 @@ vect_create_oprnd_info (int nops, int group_size) oprnd_info->first_dt = vect_uninitialized_def; oprnd_info->first_op_type = NULL_TREE; oprnd_info->first_pattern = false; + oprnd_info->second_pattern = false; oprnds_info.quick_push (oprnd_info); } @@ -242,7 +243,7 @@ vect_get_place_in_interleaving_chain (gimple stmt, gimple first_stmt) static int vect_get_and_check_slp_defs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, - gimple stmt, bool first, + gimple stmt, unsigned stmt_num, vec *oprnds_info) { tree oprnd; @@ -256,6 +257,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, int first_op_idx = 1; bool commutative = false; bool first_op_cond = false; + bool first = stmt_num == 0; + bool second = stmt_num == 1; if (loop_vinfo) loop = LOOP_VINFO_LOOP (loop_vinfo); @@ -326,7 +329,11 @@ again: && !STMT_VINFO_LIVE_P (vinfo_for_stmt (def_stmt))) { pattern = true; - if (!first && !oprnd_info->first_pattern) + if (!first && !oprnd_info->first_pattern + /* Allow different pattern state for the defs of the + first stmt in reduction chains. */ + && (oprnd_info->first_dt != vect_reduction_def + || (!second && !oprnd_info->second_pattern))) { if (i == 0 && !swapped @@ -377,6 +384,9 @@ again: } } + if (second) + oprnd_info->second_pattern = pattern; + if (first) { oprnd_info->first_dt = dt; @@ -892,7 +902,7 @@ vect_build_slp_tree_1 (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, /* Not memory operation. */ if (TREE_CODE_CLASS (rhs_code) != tcc_binary && TREE_CODE_CLASS (rhs_code) != tcc_unary - && rhs_code != COND_EXPR + && TREE_CODE_CLASS (rhs_code) != tcc_expression && rhs_code != CALL_EXPR) { if (dump_enabled_p ()) @@ -1033,7 +1043,7 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (*node), i, stmt) { switch (vect_get_and_check_slp_defs (loop_vinfo, bb_vinfo, - stmt, (i == 0), &oprnds_info)) + stmt, i, &oprnds_info)) { case 0: break; @@ -1910,17 +1920,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, max_tree_size)) ok = true; - if (bb_vinfo && !ok) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "Failed to SLP the basic block.\n"); - - return false; - } - - if (loop_vinfo - && LOOP_VINFO_REDUCTION_CHAINS (loop_vinfo).length () > 0) + if (reduc_chains.length () > 0) { /* Find SLP sequences starting from reduction chains. */ FOR_EACH_VEC_ELT (reduc_chains, i, first_element) @@ -1936,7 +1936,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo, } /* Find SLP sequences starting from groups of reductions. */ - if (loop_vinfo && LOOP_VINFO_REDUCTIONS (loop_vinfo).length () > 1 + if (reductions.length () > 1 && vect_analyze_slp_instance (loop_vinfo, bb_vinfo, reductions[0], max_tree_size)) ok = true; @@ -2443,9 +2443,13 @@ vect_slp_analyze_bb_1 (basic_block bb) if (!vect_analyze_slp (NULL, bb_vinfo, n_stmts)) { if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: failed to find SLP opportunities " - "in basic block.\n"); + { + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "Failed to SLP the basic block.\n"); + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: failed to find SLP opportunities " + "in basic block.\n"); + } destroy_bb_vec_info (bb_vinfo); return NULL; diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 17e590e67de..adde2fb0d1d 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -163,6 +163,7 @@ typedef struct _slp_oprnd_info enum vect_def_type first_dt; tree first_op_type; bool first_pattern; + bool second_pattern; } *slp_oprnd_info; -- 2.30.2