diff options
author | Ira Rosen <ira.rosen@linaro.org> | 2011-06-30 06:37:41 +0000 |
---|---|---|
committer | Ira Rosen <irar@gcc.gnu.org> | 2011-06-30 06:37:41 +0000 |
commit | 83197f37339cecf1c89724341a85aae539751f84 (patch) | |
tree | 4f3bebd5f33136e8f6f42ff799dc8c7eb3704c7e /gcc/tree-vect-stmts.c | |
parent | 0dcd5f9db100c5c9d4209c04fdbe0f5bd75f2751 (diff) | |
download | gcc-83197f37339cecf1c89724341a85aae539751f84.zip gcc-83197f37339cecf1c89724341a85aae539751f84.tar.gz gcc-83197f37339cecf1c89724341a85aae539751f84.tar.bz2 |
tree-vect-loop.c (vect_determine_vectorization_factor): Handle both pattern and original statements if necessary.
* tree-vect-loop.c (vect_determine_vectorization_factor): Handle
both pattern and original statements if necessary.
(vect_transform_loop): Likewise.
* tree-vect-patterns.c (vect_pattern_recog): Update documentation.
* tree-vect-stmts.c (vect_mark_relevant): Add new argument.
Mark the pattern statement only if the original statement doesn't
have its own uses.
(process_use): Call vect_mark_relevant with additional parameter.
(vect_mark_stmts_to_be_vectorized): Likewise.
(vect_get_vec_def_for_operand): Use vectorized pattern statement.
(vect_analyze_stmt): Handle both pattern and original statements
if necessary.
(vect_transform_stmt): Don't store vectorized pattern statement
in the original statement.
(vect_is_simple_use_1): Use related pattern statement only if the
original statement is irrelevant.
* tree-vect-slp.c (vect_get_and_check_slp_defs): Likewise.
From-SVN: r175681
Diffstat (limited to 'gcc/tree-vect-stmts.c')
-rw-r--r-- | gcc/tree-vect-stmts.c | 134 |
1 files changed, 94 insertions, 40 deletions
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 8ac2125..1d334b0 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -126,33 +126,72 @@ create_array_ref (tree type, tree ptr, struct data_reference *first_dr) static void vect_mark_relevant (VEC(gimple,heap) **worklist, gimple stmt, - enum vect_relevant relevant, bool live_p) + enum vect_relevant relevant, bool live_p, + bool used_in_pattern) { stmt_vec_info stmt_info = vinfo_for_stmt (stmt); enum vect_relevant save_relevant = STMT_VINFO_RELEVANT (stmt_info); bool save_live_p = STMT_VINFO_LIVE_P (stmt_info); + gimple pattern_stmt; if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "mark relevant %d, live %d.", relevant, live_p); + /* If this stmt is an original stmt in a pattern, we might need to mark its + related pattern stmt instead of the original stmt. However, such stmts + may have their own uses that are not in any pattern, in such cases the + stmt itself should be marked. */ if (STMT_VINFO_IN_PATTERN_P (stmt_info)) { - gimple pattern_stmt; + bool found = false; + if (!used_in_pattern) + { + imm_use_iterator imm_iter; + use_operand_p use_p; + gimple use_stmt; + tree lhs; - /* This is the last stmt in a sequence that was detected as a - pattern that can potentially be vectorized. Don't mark the stmt - as relevant/live because it's not going to be vectorized. - Instead mark the pattern-stmt that replaces it. */ + if (is_gimple_assign (stmt)) + lhs = gimple_assign_lhs (stmt); + else + lhs = gimple_call_lhs (stmt); - pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info); + /* This use is out of pattern use, if LHS has other uses that are + pattern uses, we should mark the stmt itself, and not the pattern + stmt. */ + FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) + { + if (is_gimple_debug (USE_STMT (use_p))) + continue; + use_stmt = USE_STMT (use_p); - if (vect_print_dump_info (REPORT_DETAILS)) - fprintf (vect_dump, "last stmt in pattern. don't mark relevant/live."); - stmt_info = vinfo_for_stmt (pattern_stmt); - gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == stmt); - save_relevant = STMT_VINFO_RELEVANT (stmt_info); - save_live_p = STMT_VINFO_LIVE_P (stmt_info); - stmt = pattern_stmt; + if (vinfo_for_stmt (use_stmt) + && STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt))) + { + found = true; + break; + } + } + } + + if (!found) + { + /* This is the last stmt in a sequence that was detected as a + pattern that can potentially be vectorized. Don't mark the stmt + as relevant/live because it's not going to be vectorized. + Instead mark the pattern-stmt that replaces it. */ + + pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info); + + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "last stmt in pattern. don't mark" + " relevant/live."); + stmt_info = vinfo_for_stmt (pattern_stmt); + gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == stmt); + save_relevant = STMT_VINFO_RELEVANT (stmt_info); + save_live_p = STMT_VINFO_LIVE_P (stmt_info); + stmt = pattern_stmt; + } } STMT_VINFO_LIVE_P (stmt_info) |= live_p; @@ -437,7 +476,8 @@ process_use (gimple stmt, tree use, loop_vec_info loop_vinfo, bool live_p, } } - vect_mark_relevant (worklist, def_stmt, relevant, live_p); + vect_mark_relevant (worklist, def_stmt, relevant, live_p, + is_pattern_stmt_p (stmt_vinfo)); return true; } @@ -494,7 +534,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo) } if (vect_stmt_relevant_p (phi, loop_vinfo, &relevant, &live_p)) - vect_mark_relevant (&worklist, phi, relevant, live_p); + vect_mark_relevant (&worklist, phi, relevant, live_p, false); } for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) { @@ -506,7 +546,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo) } if (vect_stmt_relevant_p (stmt, loop_vinfo, &relevant, &live_p)) - vect_mark_relevant (&worklist, stmt, relevant, live_p); + vect_mark_relevant (&worklist, stmt, relevant, live_p, false); } } @@ -1184,7 +1224,14 @@ vect_get_vec_def_for_operand (tree op, gimple stmt, tree *scalar_def) /* Get the def from the vectorized stmt. */ def_stmt_info = vinfo_for_stmt (def_stmt); + vec_stmt = STMT_VINFO_VEC_STMT (def_stmt_info); + /* Get vectorized pattern statement. */ + if (!vec_stmt + && STMT_VINFO_IN_PATTERN_P (def_stmt_info) + && !STMT_VINFO_RELEVANT (def_stmt_info)) + vec_stmt = STMT_VINFO_VEC_STMT (vinfo_for_stmt ( + STMT_VINFO_RELATED_STMT (def_stmt_info))); gcc_assert (vec_stmt); if (gimple_code (vec_stmt) == GIMPLE_PHI) vec_oprnd = PHI_RESULT (vec_stmt); @@ -4863,6 +4910,7 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vectorize, slp_tree node) enum vect_relevant relevance = STMT_VINFO_RELEVANT (stmt_info); bool ok; tree scalar_type, vectype; + gimple pattern_stmt; if (vect_print_dump_info (REPORT_DETAILS)) { @@ -4884,16 +4932,22 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vectorize, slp_tree node) - any LABEL_EXPRs in the loop - computations that are used only for array indexing or loop control. In basic blocks we only analyze statements that are a part of some SLP - instance, therefore, all the statements are relevant. */ + instance, therefore, all the statements are relevant. + Pattern statement need to be analyzed instead of the original statement + if the original statement is not relevant. Otherwise, we analyze both + statements. */ + + pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info); if (!STMT_VINFO_RELEVANT_P (stmt_info) && !STMT_VINFO_LIVE_P (stmt_info)) { - gimple pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info); if (STMT_VINFO_IN_PATTERN_P (stmt_info) + && pattern_stmt && (STMT_VINFO_RELEVANT_P (vinfo_for_stmt (pattern_stmt)) || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_stmt)))) { + /* Analyze PATTERN_STMT instead of the original stmt. */ stmt = pattern_stmt; stmt_info = vinfo_for_stmt (pattern_stmt); if (vect_print_dump_info (REPORT_DETAILS)) @@ -4910,6 +4964,21 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vectorize, slp_tree node) return true; } } + else if (STMT_VINFO_IN_PATTERN_P (stmt_info) + && pattern_stmt + && (STMT_VINFO_RELEVANT_P (vinfo_for_stmt (pattern_stmt)) + || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_stmt)))) + { + /* Analyze PATTERN_STMT too. */ + if (vect_print_dump_info (REPORT_DETAILS)) + { + fprintf (vect_dump, "==> examining pattern statement: "); + print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM); + } + + if (!vect_analyze_stmt (pattern_stmt, need_to_vectorize, node)) + return false; + } switch (STMT_VINFO_DEF_TYPE (stmt_info)) { @@ -5043,7 +5112,6 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iterator *gsi, bool is_store = false; gimple vec_stmt = NULL; stmt_vec_info stmt_info = vinfo_for_stmt (stmt); - gimple orig_stmt_in_pattern, orig_scalar_stmt = stmt; bool done; switch (STMT_VINFO_TYPE (stmt_info)) @@ -5182,25 +5250,7 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iterator *gsi, } if (vec_stmt) - { - STMT_VINFO_VEC_STMT (stmt_info) = vec_stmt; - orig_stmt_in_pattern = STMT_VINFO_RELATED_STMT (stmt_info); - if (orig_stmt_in_pattern) - { - stmt_vec_info stmt_vinfo = vinfo_for_stmt (orig_stmt_in_pattern); - /* STMT was inserted by the vectorizer to replace a computation idiom. - ORIG_STMT_IN_PATTERN is a stmt in the original sequence that - computed this idiom. We need to record a pointer to VEC_STMT in - the stmt_info of ORIG_STMT_IN_PATTERN. See more details in the - documentation of vect_pattern_recog. */ - if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo)) - { - gcc_assert (STMT_VINFO_RELATED_STMT (stmt_vinfo) - == orig_scalar_stmt); - STMT_VINFO_VEC_STMT (stmt_vinfo) = vec_stmt; - } - } - } + STMT_VINFO_VEC_STMT (stmt_info) = vec_stmt; return is_store; } @@ -5587,8 +5637,12 @@ vect_is_simple_use_1 (tree operand, loop_vec_info loop_vinfo, || *dt == vect_nested_cycle) { stmt_vec_info stmt_info = vinfo_for_stmt (*def_stmt); - if (STMT_VINFO_IN_PATTERN_P (stmt_info)) + + if (STMT_VINFO_IN_PATTERN_P (stmt_info) + && !STMT_VINFO_RELEVANT (stmt_info) + && !STMT_VINFO_LIVE_P (stmt_info)) stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); + *vectype = STMT_VINFO_VECTYPE (stmt_info); gcc_assert (*vectype != NULL_TREE); } |