aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vectorizer.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-08-24 12:25:25 +0200
committerRichard Biener <rguenther@suse.de>2021-08-24 14:23:00 +0200
commit9216ee6d1195d48388f825cf1b072e570129cbbe (patch)
tree742d1a0d6e52bd6723e3d220f48e594a49692f22 /gcc/tree-vectorizer.c
parent809330ab8450261e05919b472783bf15e4b000f7 (diff)
downloadgcc-9216ee6d1195d48388f825cf1b072e570129cbbe.zip
gcc-9216ee6d1195d48388f825cf1b072e570129cbbe.tar.gz
gcc-9216ee6d1195d48388f825cf1b072e570129cbbe.tar.bz2
tree-optimization/100089 - avoid leaving scalar if-converted code around
This avoids leaving scalar if-converted code around for the case of BB vectorizing an if-converted loop body when using the very-cheap cost model. In this case we scan not vectorized scalar stmts in the basic-block vectorized for COND_EXPRs and force the vectorization to be marked as not profitable. The patch also makes sure to always consider all BB vectorization subgraphs together for costing purposes when vectorizing an if-converted loop body. 2021-08-24 Richard Biener <rguenther@suse.de> PR tree-optimization/100089 * tree-vectorizer.h (vect_slp_bb): Rename to ... (vect_slp_if_converted_bb): ... this and get the original loop as new argument. * tree-vectorizer.c (try_vectorize_loop_1): Revert previous fix, pass original loop to vect_slp_if_converted_bb. * tree-vect-slp.c (vect_bb_vectorization_profitable_p): If orig_loop was passed scan the not vectorized stmts for COND_EXPRs and force not profitable if found. (vect_slp_region): Pass down all SLP instances to costing if orig_loop was specified. (vect_slp_bbs): Pass through orig_loop. (vect_slp_bb): Rename to ... (vect_slp_if_converted_bb): ... this and get the original loop as new argument. (vect_slp_function): Adjust.
Diffstat (limited to 'gcc/tree-vectorizer.c')
-rw-r--r--gcc/tree-vectorizer.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 813f468..3aa3e2a 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -1033,10 +1033,7 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
only non-if-converted parts took part in BB vectorization. */
if (flag_tree_slp_vectorize != 0
&& loop_vectorized_call
- && ! loop->inner
- /* This would purely be a workaround and should be removed
- once PR100089 is fixed. */
- && flag_vect_cost_model != VECT_COST_MODEL_VERY_CHEAP)
+ && ! loop->inner)
{
basic_block bb = loop->header;
bool require_loop_vectorize = false;
@@ -1062,12 +1059,17 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
gimple_set_uid (stmt, -1);
gimple_set_visited (stmt, false);
}
- if (!require_loop_vectorize && vect_slp_bb (bb))
+ if (!require_loop_vectorize)
{
- fold_loop_internal_call (loop_vectorized_call,
- boolean_true_node);
- loop_vectorized_call = NULL;
- ret |= TODO_cleanup_cfg | TODO_update_ssa_only_virtuals;
+ tree arg = gimple_call_arg (loop_vectorized_call, 1);
+ class loop *scalar_loop = get_loop (cfun, tree_to_shwi (arg));
+ if (vect_slp_if_converted_bb (bb, scalar_loop))
+ {
+ fold_loop_internal_call (loop_vectorized_call,
+ boolean_true_node);
+ loop_vectorized_call = NULL;
+ ret |= TODO_cleanup_cfg | TODO_update_ssa_only_virtuals;
+ }
}
}
/* If outer loop vectorization fails for LOOP_VECTORIZED guarded