diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-07-27 10:15:41 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-07-27 10:15:41 -0700 |
commit | 9f62ed218fa656607740b386c0caa03e65dcd283 (patch) | |
tree | 6bde49bc5e4c4241266b108e4277baef4b85535d /gcc/tree-vectorizer.cc | |
parent | 71e955da39cea0ebffcfee3432effa622d14ca99 (diff) | |
parent | 5eb9f117a361538834b9740d59219911680717d1 (diff) | |
download | gcc-9f62ed218fa656607740b386c0caa03e65dcd283.zip gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.gz gcc-9f62ed218fa656607740b386c0caa03e65dcd283.tar.bz2 |
Merge from trunk revision 5eb9f117a361538834b9740d59219911680717d1.
Diffstat (limited to 'gcc/tree-vectorizer.cc')
-rw-r--r-- | gcc/tree-vectorizer.cc | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc index 344dc41..6ec4951 100644 --- a/gcc/tree-vectorizer.cc +++ b/gcc/tree-vectorizer.cc @@ -82,6 +82,7 @@ along with GCC; see the file COPYING3. If not see #include "opt-problem.h" #include "internal-fn.h" #include "tree-ssa-sccvn.h" +#include "tree-into-ssa.h" /* Loop or bb location, with hotness information. */ dump_user_location_t vect_location; @@ -99,7 +100,8 @@ auto_purge_vect_location::~auto_purge_vect_location () void dump_stmt_cost (FILE *f, int count, enum vect_cost_for_stmt kind, - stmt_vec_info stmt_info, tree, int misalign, unsigned cost, + stmt_vec_info stmt_info, slp_tree node, tree, + int misalign, unsigned cost, enum vect_cost_model_location where) { if (stmt_info) @@ -107,6 +109,8 @@ dump_stmt_cost (FILE *f, int count, enum vect_cost_for_stmt kind, print_gimple_expr (f, STMT_VINFO_STMT (stmt_info), 0, TDF_SLIM); fprintf (f, " "); } + else if (node) + fprintf (f, "node %p ", (void *)node); else fprintf (f, "<unknown> "); fprintf (f, "%d times ", count); @@ -979,7 +983,7 @@ set_uid_loop_bbs (loop_vec_info loop_vinfo, gimple *loop_vectorized_call, /* Generate vectorized code for LOOP and its epilogues. */ -static void +static unsigned vect_transform_loops (hash_table<simduid_to_vf> *&simduid_to_vf_htab, loop_p loop, gimple *loop_vectorized_call, function *fun) @@ -1017,9 +1021,25 @@ vect_transform_loops (hash_table<simduid_to_vf> *&simduid_to_vf_htab, = simduid_to_vf_data; } + /* We should not have to update virtual SSA form here but some + transforms involve creating new virtual definitions which makes + updating difficult. + We delay the actual update to the end of the pass but avoid + confusing ourselves by forcing need_ssa_update_p () to false. */ + unsigned todo = 0; + if (need_ssa_update_p (cfun)) + { + gcc_assert (loop_vinfo->any_known_not_updated_vssa); + fun->gimple_df->ssa_renaming_needed = false; + todo |= TODO_update_ssa_only_virtuals; + } + gcc_assert (!need_ssa_update_p (cfun)); + /* Epilogue of vectorized loop must be vectorized too. */ if (new_loop) - vect_transform_loops (simduid_to_vf_htab, new_loop, NULL, fun); + todo |= vect_transform_loops (simduid_to_vf_htab, new_loop, NULL, fun); + + return todo; } /* Try to vectorize LOOP. */ @@ -1130,7 +1150,8 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab, (*num_vectorized_loops)++; /* Transform LOOP and its epilogues. */ - vect_transform_loops (simduid_to_vf_htab, loop, loop_vectorized_call, fun); + ret |= vect_transform_loops (simduid_to_vf_htab, loop, + loop_vectorized_call, fun); if (loop_vectorized_call) { @@ -1190,12 +1211,12 @@ public: {} /* opt_pass methods: */ - virtual bool gate (function *fun) + bool gate (function *fun) final override { return flag_tree_loop_vectorize || fun->has_force_vectorize_loops; } - virtual unsigned int execute (function *); + unsigned int execute (function *) final override; }; // class pass_vectorize @@ -1329,6 +1350,11 @@ pass_vectorize::execute (function *fun) if (num_vectorized_loops > 0) { + /* We are collecting some corner cases where we need to update + virtual SSA form via the TODO but delete the queued update-SSA + state. Force renaming if we think that might be necessary. */ + if (ret & TODO_update_ssa_only_virtuals) + mark_virtual_operands_for_renaming (cfun); /* If we vectorized any loop only virtual SSA form needs to be updated. ??? Also while we try hard to update loop-closed SSA form we fail to properly do this in some corner-cases (see PR56286). */ @@ -1402,9 +1428,12 @@ public: {} /* opt_pass methods: */ - opt_pass * clone () { return new pass_simduid_cleanup (m_ctxt); } - virtual bool gate (function *fun) { return fun->has_simduid_loops; } - virtual unsigned int execute (function *); + opt_pass * clone () final override + { + return new pass_simduid_cleanup (m_ctxt); + } + bool gate (function *fun) final override { return fun->has_simduid_loops; } + unsigned int execute (function *) final override; }; // class pass_simduid_cleanup @@ -1460,9 +1489,9 @@ public: {} /* opt_pass methods: */ - opt_pass * clone () { return new pass_slp_vectorize (m_ctxt); } - virtual bool gate (function *) { return flag_tree_slp_vectorize != 0; } - virtual unsigned int execute (function *); + opt_pass * clone () final override { return new pass_slp_vectorize (m_ctxt); } + bool gate (function *) final override { return flag_tree_slp_vectorize != 0; } + unsigned int execute (function *) final override; }; // class pass_slp_vectorize @@ -1693,12 +1722,15 @@ public: {} /* opt_pass methods: */ - virtual bool gate (function *) + bool gate (function *) final override { return flag_section_anchors && flag_tree_loop_vectorize; } - virtual unsigned int execute (function *) { return increase_alignment (); } + unsigned int execute (function *) final override + { + return increase_alignment (); + } }; // class pass_ipa_increase_alignment @@ -1766,8 +1798,9 @@ scalar_cond_masked_key::get_cond_ops_from_tree (tree t) unsigned int vector_costs::add_stmt_cost (int count, vect_cost_for_stmt kind, - stmt_vec_info stmt_info, tree vectype, - int misalign, vect_cost_model_location where) + stmt_vec_info stmt_info, slp_tree, + tree vectype, int misalign, + vect_cost_model_location where) { unsigned int cost = builtin_vectorization_cost (kind, vectype, misalign) * count; |