diff options
author | Ira Rosen <ira.rosen@linaro.org> | 2011-04-28 19:50:28 +0000 |
---|---|---|
committer | Ira Rosen <irar@gcc.gnu.org> | 2011-04-28 19:50:28 +0000 |
commit | 437f4a0024d9829a138ad1f5b0311cbf4289d5e3 (patch) | |
tree | d74e91634ee0c939232faa3f82d1f68d10da27ba /gcc/tree-vect-loop.c | |
parent | 45540bcf241167158663d4e7970749c103a8afd2 (diff) | |
download | gcc-437f4a0024d9829a138ad1f5b0311cbf4289d5e3.zip gcc-437f4a0024d9829a138ad1f5b0311cbf4289d5e3.tar.gz gcc-437f4a0024d9829a138ad1f5b0311cbf4289d5e3.tar.bz2 |
re PR tree-optimization/48765 (ICE in vect_transform_stmt)
PR tree-optimization/48765
* tree-vectorizer.h (vect_make_slp_decision): Return bool.
* tree-vect-loop.c (vect_analyze_loop_operations): Add new
argument to indicate if loop aware SLP is being used. Scan
the statements and update the vectorization factor
according to the type of
vectorization before statement analysis.
(vect_analyze_loop_2): Get a return value from
vect_make_slp_decision, pass it to
vect_analyze_loop_operations.
(vectorizable_reduction): Set number of copies to 1 in case of
pure SLP statement.
* tree-vect-stmts.c (vectorizable_conversion,
vectorizable_assignment, vectorizable_shift,
vectorizable_operation, vectorizable_type_demotion,
vectorizable_type_promotion, vectorizable_store,
vectorizable_load): Likewise.
(vectorizable_condition): Move the check that it is not SLP
vectorization before the number of copies check.
* tree-vect-slp.c (vect_make_slp_decision): Return TRUE if
decided to vectorize the loop using SLP.
From-SVN: r173132
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 66 |
1 files changed, 39 insertions, 27 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 5fecf2a..e05c324 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1146,7 +1146,7 @@ vect_get_cost (enum vect_cost_for_stmt type_of_cost) Scan the loop stmts and make sure they are all vectorizable. */ static bool -vect_analyze_loop_operations (loop_vec_info loop_vinfo) +vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp) { struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo); @@ -1167,6 +1167,40 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) gcc_assert (LOOP_VINFO_VECT_FACTOR (loop_vinfo)); vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo); + if (slp) + { + /* If all the stmts in the loop can be SLPed, we perform only SLP, and + vectorization factor of the loop is the unrolling factor required by + the SLP instances. If that unrolling factor is 1, we say, that we + perform pure SLP on loop - cross iteration parallelism is not + exploited. */ + for (i = 0; i < nbbs; i++) + { + basic_block bb = bbs[i]; + for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) + { + gimple stmt = gsi_stmt (si); + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + gcc_assert (stmt_info); + if ((STMT_VINFO_RELEVANT_P (stmt_info) + || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info))) + && !PURE_SLP_STMT (stmt_info)) + /* STMT needs both SLP and loop-based vectorization. */ + only_slp_in_loop = false; + } + } + + if (only_slp_in_loop) + vectorization_factor = LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo); + else + vectorization_factor = least_common_multiple (vectorization_factor, + LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo)); + + LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor; + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "Updating vectorization factor to %d ", + vectorization_factor); + } for (i = 0; i < nbbs; i++) { @@ -1272,18 +1306,8 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si)) { gimple stmt = gsi_stmt (si); - stmt_vec_info stmt_info = vinfo_for_stmt (stmt); - - gcc_assert (stmt_info); - if (!vect_analyze_stmt (stmt, &need_to_vectorize, NULL)) return false; - - if ((STMT_VINFO_RELEVANT_P (stmt_info) - || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info))) - && !PURE_SLP_STMT (stmt_info)) - /* STMT needs both SLP and loop-based vectorization. */ - only_slp_in_loop = false; } } /* bbs */ @@ -1303,18 +1327,6 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) return false; } - /* If all the stmts in the loop can be SLPed, we perform only SLP, and - vectorization factor of the loop is the unrolling factor required by the - SLP instances. If that unrolling factor is 1, we say, that we perform - pure SLP on loop - cross iteration parallelism is not exploited. */ - if (only_slp_in_loop) - vectorization_factor = LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo); - else - vectorization_factor = least_common_multiple (vectorization_factor, - LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo)); - - LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor; - if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo) && vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, @@ -1410,7 +1422,7 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo) static bool vect_analyze_loop_2 (loop_vec_info loop_vinfo) { - bool ok, dummy; + bool ok, dummy, slp = false; int max_vf = MAX_VECTORIZATION_FACTOR; int min_vf = 2; @@ -1524,7 +1536,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo) if (ok) { /* Decide which possible SLP instances to SLP. */ - vect_make_slp_decision (loop_vinfo); + slp = vect_make_slp_decision (loop_vinfo); /* Find stmts that need to be both vectorized and SLPed. */ vect_detect_hybrid_slp (loop_vinfo); @@ -1533,7 +1545,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo) /* Scan all the operations in the loop and make sure they are vectorizable. */ - ok = vect_analyze_loop_operations (loop_vinfo); + ok = vect_analyze_loop_operations (loop_vinfo, slp); if (!ok) { if (vect_print_dump_info (REPORT_DETAILS)) @@ -4136,7 +4148,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_iterator *gsi, if (STMT_VINFO_LIVE_P (vinfo_for_stmt (reduc_def_stmt))) return false; - if (slp_node) + if (slp_node || PURE_SLP_STMT (stmt_info)) ncopies = 1; else ncopies = (LOOP_VINFO_VECT_FACTOR (loop_vinfo) |