On Tue, Jul 3, 2018 at 10:10 AM Richard Sandiford <richard.sandif...@arm.com> wrote: > > Various recognisers set PATTERN_DEF_SEQ to null before adding > statements to it, but it should always be null at that point anyway. > This patch asserts for that in vect_pattern_recog_1 and removes > the redundant code. > > Tested on aarch64-linux-gnu, arm-linux-gnueabihf and x86_64-linux-gnu. > OK to install?
OK. Thanks, Richard. > Richard > > > 2018-07-03 Richard Sandiford <richard.sandif...@arm.com> > > gcc/ > * tree-vect-patterns.c (new_pattern_def_seq): Delete. > (vect_recog_dot_prod_pattern, vect_recog_sad_pattern) > (vect_recog_widen_op_pattern, vect_recog_over_widening_pattern) > (vect_recog_rotate_pattern, vect_synth_mult_by_constant): Don't set > STMT_VINFO_PATTERN_DEF_SEQ to null here. > (vect_recog_pow_pattern, vect_recog_vector_vector_shift_pattern) > (vect_recog_mixed_size_cond_pattern, vect_recog_bool_pattern): Use > append_pattern_def_seq instead of new_pattern_def_seq. > (vect_recog_divmod_pattern): Do both of the above. > (vect_pattern_recog_1): Assert that STMT_VINO_PATTERN_DEF_SEQ > is null. > > Index: gcc/tree-vect-patterns.c > =================================================================== > --- gcc/tree-vect-patterns.c 2018-07-03 09:03:39.834882009 +0100 > +++ gcc/tree-vect-patterns.c 2018-07-03 09:06:43.861330261 +0100 > @@ -150,13 +150,6 @@ append_pattern_def_seq (stmt_vec_info st > new_stmt); > } > > -static inline void > -new_pattern_def_seq (stmt_vec_info stmt_info, gimple *stmt) > -{ > - STMT_VINFO_PATTERN_DEF_SEQ (stmt_info) = NULL; > - append_pattern_def_seq (stmt_info, stmt); > -} > - > /* The caller wants to perform new operations on vect_external variable > VAR, so that the result of the operations would also be vect_external. > Return the edge on which the operations can be performed, if one exists. > @@ -983,7 +976,6 @@ vect_recog_dot_prod_pattern (stmt_vec_in > return NULL; > > /* Get the inputs in the appropriate types. */ > - STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo) = NULL; > tree mult_oprnd[2]; > vect_convert_inputs (stmt_vinfo, 2, mult_oprnd, half_type, > unprom0, half_vectype); > @@ -1142,7 +1134,6 @@ vect_recog_sad_pattern (stmt_vec_info st > return NULL; > > /* Get the inputs to the SAD_EXPR in the appropriate types. */ > - STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo) = NULL; > tree sad_oprnd[2]; > vect_convert_inputs (stmt_vinfo, 2, sad_oprnd, half_type, > unprom, half_vectype); > @@ -1220,7 +1211,6 @@ vect_recog_widen_op_pattern (stmt_vec_in > if (!*type_out) > return NULL; > > - STMT_VINFO_PATTERN_DEF_SEQ (last_stmt_info) = NULL; > tree oprnd[2]; > vect_convert_inputs (last_stmt_info, 2, oprnd, half_type, unprom, vectype); > > @@ -1342,7 +1332,7 @@ vect_recog_pow_pattern (stmt_vec_info st > return NULL; > tree def = vect_recog_temp_ssa_var (TREE_TYPE (base), NULL); > gimple *g = gimple_build_assign (def, MULT_EXPR, exp, logc); > - new_pattern_def_seq (stmt_vinfo, g); > + append_pattern_def_seq (stmt_vinfo, g); > tree res = vect_recog_temp_ssa_var (TREE_TYPE (base), NULL); > g = gimple_build_call (exp_decl, 1, def); > gimple_call_set_lhs (g, res); > @@ -1687,7 +1677,6 @@ vect_recog_over_widening_pattern (stmt_v > } > > /* Calculate the rhs operands for an operation on NEW_TYPE. */ > - STMT_VINFO_PATTERN_DEF_SEQ (last_stmt_info) = NULL; > tree ops[3] = {}; > for (unsigned int i = 1; i < first_op; ++i) > ops[i - 1] = gimple_op (last_stmt, i); > @@ -2073,7 +2062,6 @@ vect_recog_rotate_pattern (stmt_vec_info > def = rhs1; > } > > - STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo) = NULL; > if (def == NULL_TREE) > { > def = vect_recog_temp_ssa_var (type, NULL); > @@ -2269,7 +2257,7 @@ vect_recog_vector_vector_shift_pattern ( > set_vinfo_for_stmt (def_stmt, new_stmt_info); > STMT_VINFO_VECTYPE (new_stmt_info) > = get_vectype_for_scalar_type (TREE_TYPE (rhs1)); > - new_pattern_def_seq (stmt_vinfo, def_stmt); > + append_pattern_def_seq (stmt_vinfo, def_stmt); > } > } > } > @@ -2278,7 +2266,7 @@ vect_recog_vector_vector_shift_pattern ( > { > def = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL); > def_stmt = gimple_build_assign (def, NOP_EXPR, oprnd1); > - new_pattern_def_seq (stmt_vinfo, def_stmt); > + append_pattern_def_seq (stmt_vinfo, def_stmt); > } > > /* Pattern detected. */ > @@ -2472,7 +2460,6 @@ vect_synth_mult_by_constant (tree op, tr > tree accumulator; > > /* Clear out the sequence of statements so we can populate it below. */ > - STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo) = NULL; > gimple *stmt = NULL; > > if (cast_to_unsigned_p) > @@ -2769,7 +2756,7 @@ vect_recog_divmod_pattern (stmt_vec_info > fold_build2 (MINUS_EXPR, itype, oprnd1, > build_int_cst (itype, 1)), > build_int_cst (itype, 0)); > - new_pattern_def_seq (stmt_vinfo, def_stmt); > + append_pattern_def_seq (stmt_vinfo, def_stmt); > var = vect_recog_temp_ssa_var (itype, NULL); > def_stmt > = gimple_build_assign (var, PLUS_EXPR, oprnd0, > @@ -2784,7 +2771,6 @@ vect_recog_divmod_pattern (stmt_vec_info > else > { > tree signmask; > - STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo) = NULL; > if (compare_tree_int (oprnd1, 2) == 0) > { > signmask = vect_recog_temp_ssa_var (itype, NULL); > @@ -2851,8 +2837,6 @@ vect_recog_divmod_pattern (stmt_vec_info > if (!can_mult_highpart_p (TYPE_MODE (vectype), TYPE_UNSIGNED (itype))) > return NULL; > > - STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo) = NULL; > - > if (TYPE_UNSIGNED (itype)) > { > unsigned HOST_WIDE_INT mh, ml; > @@ -3234,7 +3218,7 @@ vect_recog_mixed_size_cond_pattern (stmt > pattern_stmt = gimple_build_assign (vect_recog_temp_ssa_var (type, NULL), > NOP_EXPR, gimple_assign_lhs (def_stmt)); > > - new_pattern_def_seq (stmt_vinfo, def_stmt); > + append_pattern_def_seq (stmt_vinfo, def_stmt); > def_stmt_info = new_stmt_vec_info (def_stmt, vinfo); > set_vinfo_for_stmt (def_stmt, def_stmt_info); > STMT_VINFO_VECTYPE (def_stmt_info) = vecitype; > @@ -3796,7 +3780,7 @@ vect_recog_bool_pattern (stmt_vec_info s > new_stmt_info = new_stmt_vec_info (pattern_stmt, vinfo); > set_vinfo_for_stmt (pattern_stmt, new_stmt_info); > STMT_VINFO_VECTYPE (new_stmt_info) = new_vectype; > - new_pattern_def_seq (stmt_vinfo, pattern_stmt); > + append_pattern_def_seq (stmt_vinfo, pattern_stmt); > > lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL); > pattern_stmt = gimple_build_assign (lhs, CONVERT_EXPR, tmp); > @@ -4899,6 +4883,7 @@ vect_pattern_recog_1 (vect_recog_func *r > return; > } > > + gcc_assert (!STMT_VINFO_PATTERN_DEF_SEQ (stmt_info)); > pattern_stmt = recog_func->fn (stmt_info, &pattern_vectype); > if (!pattern_stmt) > {