Re: [11/46] Pass back a stmt_vec_info from vect_is_simple_use
On Tue, Jul 24, 2018 at 11:57 AM Richard Sandiford wrote: > > This patch makes vect_is_simple_use pass back a stmt_vec_info to > those callers that want it. Most users only need the stmt_vec_info > but some need the gimple stmt too. Hmm. Unfortunately it's not redundant for dt_extern ... > It's probably high time we added a class to represent "simple operands" > instead, but I have a separate series that tries to clean up how > operands are handled (with a view to allowing mixed vector sizes). Well, we need to do sth similar to SLP and allow annotation on SSA use edges, thus operand info needs to be context dependent. One of my "plans" was to move everything over to the SLP datastructure (imperfect as it is) to make that the "single" representation of stuff. A very simple experiment allowing group sizes of one in SLP detection worked reasonably well (and exposed all the cases we do not yet handle in SLP ...). OK. Richard. > > 2018-07-24 Richard Sandiford > > gcc/ > * tree-vectorizer.h (vect_is_simple_use): Add an optional > stmt_vec_info * parameter before the optional gimple **. > * tree-vect-stmts.c (vect_is_simple_use): Likewise. > (process_use, vect_get_vec_def_for_operand_1): Update callers. > (vect_get_vec_def_for_operand, vectorizable_shift): Likewise. > * tree-vect-loop.c (vectorizable_reduction): Likewise. > (vectorizable_live_operation): Likewise. > * tree-vect-patterns.c (type_conversion_p): Likewise. > (vect_look_through_possible_promotion): Likewise. > (vect_recog_rotate_pattern): Likewise. > * tree-vect-slp.c (vect_get_and_check_slp_defs): Likewise. > > Index: gcc/tree-vectorizer.h > === > --- gcc/tree-vectorizer.h 2018-07-24 10:22:33.829278607 +0100 > +++ gcc/tree-vectorizer.h 2018-07-24 10:22:37.257248166 +0100 > @@ -1532,9 +1532,10 @@ extern tree get_mask_type_for_scalar_typ > extern tree get_same_sized_vectype (tree, tree); > extern bool vect_get_loop_mask_type (loop_vec_info); > extern bool vect_is_simple_use (tree, vec_info *, enum vect_def_type *, > - gimple ** = NULL); > + stmt_vec_info * = NULL, gimple ** = NULL); > extern bool vect_is_simple_use (tree, vec_info *, enum vect_def_type *, > - tree *, gimple ** = NULL); > + tree *, stmt_vec_info * = NULL, > + gimple ** = NULL); > extern bool supportable_widening_operation (enum tree_code, gimple *, tree, > tree, enum tree_code *, > enum tree_code *, int *, > Index: gcc/tree-vect-stmts.c > === > --- gcc/tree-vect-stmts.c 2018-07-24 10:22:33.829278607 +0100 > +++ gcc/tree-vect-stmts.c 2018-07-24 10:22:37.257248166 +0100 > @@ -459,11 +459,9 @@ process_use (gimple *stmt, tree use, loo > enum vect_relevant relevant, vec *worklist, > bool force) > { > - struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); >stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt); >stmt_vec_info dstmt_vinfo; >basic_block bb, def_bb; > - gimple *def_stmt; >enum vect_def_type dt; > >/* case 1: we are only interested in uses that need to be vectorized. Uses > @@ -471,7 +469,7 @@ process_use (gimple *stmt, tree use, loo >if (!force && !exist_non_indexing_operands_for_use_p (use, stmt)) > return true; > > - if (!vect_is_simple_use (use, loop_vinfo, , _stmt)) > + if (!vect_is_simple_use (use, loop_vinfo, , _vinfo)) > { >if (dump_enabled_p ()) > dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, > @@ -479,27 +477,20 @@ process_use (gimple *stmt, tree use, loo >return false; > } > > - if (!def_stmt || gimple_nop_p (def_stmt)) > + if (!dstmt_vinfo) > return true; > > - def_bb = gimple_bb (def_stmt); > - if (!flow_bb_inside_loop_p (loop, def_bb)) > -{ > - if (dump_enabled_p ()) > - dump_printf_loc (MSG_NOTE, vect_location, "def_stmt is out of > loop.\n"); > - return true; > -} > + def_bb = gimple_bb (dstmt_vinfo->stmt); > > - /* case 2: A reduction phi (STMT) defined by a reduction stmt (DEF_STMT). > - DEF_STMT must have already been processed, because this should be the > + /* case 2: A reduction phi (STMT) defined by a reduction stmt > (DSTMT_VINFO). > + DSTMT_VINFO must have already been processed, because this should be the > only way that STMT, which is a reduction-phi, was put in the worklist, > - as there should be no other uses for DEF_STMT in the loop. So we just > + as there should be no other uses for DSTMT_VINFO in the loop. So we > just > check that everything is as expected, and we are done. */ > -
[11/46] Pass back a stmt_vec_info from vect_is_simple_use
This patch makes vect_is_simple_use pass back a stmt_vec_info to those callers that want it. Most users only need the stmt_vec_info but some need the gimple stmt too. It's probably high time we added a class to represent "simple operands" instead, but I have a separate series that tries to clean up how operands are handled (with a view to allowing mixed vector sizes). 2018-07-24 Richard Sandiford gcc/ * tree-vectorizer.h (vect_is_simple_use): Add an optional stmt_vec_info * parameter before the optional gimple **. * tree-vect-stmts.c (vect_is_simple_use): Likewise. (process_use, vect_get_vec_def_for_operand_1): Update callers. (vect_get_vec_def_for_operand, vectorizable_shift): Likewise. * tree-vect-loop.c (vectorizable_reduction): Likewise. (vectorizable_live_operation): Likewise. * tree-vect-patterns.c (type_conversion_p): Likewise. (vect_look_through_possible_promotion): Likewise. (vect_recog_rotate_pattern): Likewise. * tree-vect-slp.c (vect_get_and_check_slp_defs): Likewise. Index: gcc/tree-vectorizer.h === --- gcc/tree-vectorizer.h 2018-07-24 10:22:33.829278607 +0100 +++ gcc/tree-vectorizer.h 2018-07-24 10:22:37.257248166 +0100 @@ -1532,9 +1532,10 @@ extern tree get_mask_type_for_scalar_typ extern tree get_same_sized_vectype (tree, tree); extern bool vect_get_loop_mask_type (loop_vec_info); extern bool vect_is_simple_use (tree, vec_info *, enum vect_def_type *, - gimple ** = NULL); + stmt_vec_info * = NULL, gimple ** = NULL); extern bool vect_is_simple_use (tree, vec_info *, enum vect_def_type *, - tree *, gimple ** = NULL); + tree *, stmt_vec_info * = NULL, + gimple ** = NULL); extern bool supportable_widening_operation (enum tree_code, gimple *, tree, tree, enum tree_code *, enum tree_code *, int *, Index: gcc/tree-vect-stmts.c === --- gcc/tree-vect-stmts.c 2018-07-24 10:22:33.829278607 +0100 +++ gcc/tree-vect-stmts.c 2018-07-24 10:22:37.257248166 +0100 @@ -459,11 +459,9 @@ process_use (gimple *stmt, tree use, loo enum vect_relevant relevant, vec *worklist, bool force) { - struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt); stmt_vec_info dstmt_vinfo; basic_block bb, def_bb; - gimple *def_stmt; enum vect_def_type dt; /* case 1: we are only interested in uses that need to be vectorized. Uses @@ -471,7 +469,7 @@ process_use (gimple *stmt, tree use, loo if (!force && !exist_non_indexing_operands_for_use_p (use, stmt)) return true; - if (!vect_is_simple_use (use, loop_vinfo, , _stmt)) + if (!vect_is_simple_use (use, loop_vinfo, , _vinfo)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, @@ -479,27 +477,20 @@ process_use (gimple *stmt, tree use, loo return false; } - if (!def_stmt || gimple_nop_p (def_stmt)) + if (!dstmt_vinfo) return true; - def_bb = gimple_bb (def_stmt); - if (!flow_bb_inside_loop_p (loop, def_bb)) -{ - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, "def_stmt is out of loop.\n"); - return true; -} + def_bb = gimple_bb (dstmt_vinfo->stmt); - /* case 2: A reduction phi (STMT) defined by a reduction stmt (DEF_STMT). - DEF_STMT must have already been processed, because this should be the + /* case 2: A reduction phi (STMT) defined by a reduction stmt (DSTMT_VINFO). + DSTMT_VINFO must have already been processed, because this should be the only way that STMT, which is a reduction-phi, was put in the worklist, - as there should be no other uses for DEF_STMT in the loop. So we just + as there should be no other uses for DSTMT_VINFO in the loop. So we just check that everything is as expected, and we are done. */ - dstmt_vinfo = vinfo_for_stmt (def_stmt); bb = gimple_bb (stmt); if (gimple_code (stmt) == GIMPLE_PHI && STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def - && gimple_code (def_stmt) != GIMPLE_PHI + && gimple_code (dstmt_vinfo->stmt) != GIMPLE_PHI && STMT_VINFO_DEF_TYPE (dstmt_vinfo) == vect_reduction_def && bb->loop_father == def_bb->loop_father) { @@ -514,7 +505,7 @@ process_use (gimple *stmt, tree use, loo /* case 3a: outer-loop stmt defining an inner-loop stmt: outer-loop-header-bb: - d = def_stmt + d = dstmt_vinfo inner-loop: stmt # use (d) outer-loop-tail-bb: @@ -554,7 +545,7 @@ process_use (gimple *stmt, tree