On 08/28/2018 05:22 AM, Richard Sandiford wrote:
> This patch adds a vec_basic_block that records the scalar phis and
> scalar statements that we need to vectorise.  This is a slight
> simplification in its own right, since it avoids unnecesary statement
> lookups and shaves >50 LOC.  But the main reason for doing it is
> to allow the rest of the series to treat pattern statements less
> specially.
> 
> Putting phis (which are logically parallel) and normal statements
> (which are logically serial) into a single list might seem dangerous,
> but I think in practice it should be fine.  Very little vectoriser
> code needs to handle the parallel nature of phis specially, and code
> that does can still do so.  Having a single list simplifies code that
> wants to look at every scalar phi or stmt in isolation.
> 
> The new test is for cases in which we try to hoist the same expression
> twice, which I broke with an earlier version of the patch.
> 
> 
> 2018-08-28  Richard Sandiford  <richard.sandif...@arm.com>
> 
> gcc/
>       * tree-vectorizer.h (vec_basic_block): New structure.
>       (vec_info::blocks, _stmt_vec_info::block, _stmt_vec_info::prev)
>       (_stmt_vec_info::next): New member variables.
>       (FOR_EACH_VEC_BB_STMT, FOR_EACH_VEC_BB_STMT_REVERSE): New macros.
>       (vec_basic_block::vec_basic_block): New function.
>       * tree-vectorizer.c (vec_basic_block::add_to_end): Likewise.
>       (vec_basic_block::add_before): Likewise.
>       (vec_basic_block::remove): Likewise.
>       (vec_info::~vec_info): Free the vec_basic_blocks.
>       (vec_info::remove_stmt): Remove the statement from the containing
>       vec_basic_block.
>       * tree-vect-patterns.c (vect_determine_precisions)
>       (vect_pattern_recog): Iterate over vec_basic_blocks.
>       * tree-vect-loop.c (vect_determine_vectorization_factor)
>       (vect_compute_single_scalar_iteration_cost, vect_update_vf_for_slp)
>       (vect_analyze_loop_operations, vect_transform_loop): Likewise.
>       (_loop_vec_info::_loop_vec_info): Construct vec_basic_blocks.
>       * tree-vect-slp.c (_bb_vec_info::_bb_vec_info): Likewise.
>       (vect_detect_hybrid_slp): Iterate over vec_basic_blocks.
>       * tree-vect-stmts.c (vect_mark_stmts_to_be_vectorized): Likewise.
>       (vect_finish_replace_stmt, vectorizable_condition): Remove the original
>       statement from the containing block.
>       (hoist_defs_of_uses): Likewise the statement that we're hoisting.
> 
> gcc/testsuite/
>       * gcc.dg/vect/vect-hoist-1.c: New test.
> 
I'm generally not a fan of references to "this" like you do when you add
STMT_INFOs to a VEC_BASIC_BLOCK.  I'm going to trust you're not leaving
dangling pointers in the STMT_INFOs and that storing a pointer to the
containing VEC_BASIC_BLOCK within the STMT_INFO is the best way to get
at the data you want.

Firstly standard doubly linked list routines, lots of fairly mechanical
chunks get simplified a bit.   Overall it looks quite reasonable.

OK for the trunk.

jeff

Reply via email to