GCC Middle and Back End API Reference
|
#include "diagnostic-core.h"
Variables | |
static vect_recog_func_ptr | vect_vect_recog_func_ptrs [NUM_PATTERNS] |
|
static |
Helper function of vect_recog_bool_pattern. Do the actual transformations, recursively. VAR is an SSA_NAME that should be transformed from bool to a wider integer type, OUT_TYPE is the desired final integer type of the whole pattern, TRUEVAL should be NULL unless optimizing BIT_AND_EXPR into a COND_EXPR with one integer from one of the operands in the then_clause, STMTS is where statements with added pattern stmts should be pushed to.
References absu_hwi(), adjust_bool_pattern_cast(), build_int_cst(), build_nonstandard_integer_type(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_location(), gimple_set_location(), tcc_comparison, useless_type_conversion_p(), vect_recog_temp_ssa_var(), and vinfo_for_stmt().
Referenced by vect_recog_bool_pattern().
|
static |
Helper function of adjust_bool_pattern. Add a cast to TYPE to a previous stmt (SSA_NAME_DEF_STMT of VAR) by moving the COND_EXPR from RELATED_STMT to PATTERN_DEF_SEQ and adding a cast as RELATED_STMT.
References gimple_assign_lhs(), gimple_build_assign_with_ops(), new_pattern_def_seq(), vect_recog_temp_ssa_var(), and vinfo_for_stmt().
Referenced by adjust_bool_pattern().
|
inlinestatic |
References gimple_seq_add_stmt_without_update().
Referenced by new_pattern_def_seq(), vect_recog_divmod_pattern(), and vect_recog_rotate_pattern().
|
static |
Helper function of vect_recog_bool_pattern. Called recursively, return true if bool VAR can be optimized that way.
References build_nonstandard_integer_type(), expand_vec_cond_expr_p(), get_vectype_for_scalar_type(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), has_single_use(), is_gimple_assign(), stmt_could_throw_p(), tcc_comparison, vect_internal_def, and vect_is_simple_use().
Referenced by vect_recog_bool_pattern().
|
inlinestatic |
|
static |
Check whether NAME, an ssa-name used in USE_STMT, is a result of a type promotion or demotion, such that: DEF_STMT: NAME = NOP (name0) where the type of name0 (ORIG_TYPE) is smaller/bigger than the type of NAME. If CHECK_SIGN is TRUE, check that either both types are signed or both are unsigned.
References gimple_assign_rhs1(), gimple_assign_rhs_code(), is_gimple_assign(), vect_constant_def, vect_external_def, vect_internal_def, vect_is_simple_use(), and vinfo_for_stmt().
Referenced by vect_operation_fits_smaller_type(), vect_recog_dot_prod_pattern(), vect_recog_mixed_size_cond_pattern(), vect_recog_widen_mult_pattern(), vect_recog_widen_shift_pattern(), and vect_recog_widen_sum_pattern().
|
static |
Handle widening operation by a constant. At the moment we support MULT_EXPR and LSHIFT_EXPR. For MULT_EXPR we check that CONST_OPRND fits HALF_TYPE, and for LSHIFT_EXPR we check that CONST_OPRND is less or equal to the size of HALF_TYPE. Otherwise, if the type of the result (TYPE) is at least 4 times bigger than HALF_TYPE, and there is an intermediate type (2 times smaller than TYPE) that satisfies the above restrictions, we can perform a widening opeartion from the intermediate type to TYPE and replace a_T = (TYPE) a_t; with a_it = (interm_type) a_t;
References build_nonstandard_integer_type(), compare_tree_int(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), int_fits_type_p(), is_gimple_assign(), make_ssa_name(), vect_same_loop_or_bb_p(), and vinfo_for_stmt().
Referenced by vect_recog_widen_mult_pattern(), and vect_recog_widen_shift_pattern().
|
inlinestatic |
Mark statements that are involved in a pattern.
References gimple_set_bb(), gsi_end_p(), gsi_next(), gsi_stmt(), new_stmt_vec_info(), set_vinfo_for_stmt(), si, and vinfo_for_stmt().
Referenced by vect_pattern_recog_1().
|
static |
Return TRUE if the operation in STMT can be performed on a smaller type. Input: STMT - a statement to check. DEF - we support operations with two operands, one of which is constant. The other operand can be defined by a demotion operation, or by a previous statement in a sequence of over-promoted operations. In the later case DEF is used to replace that operand. (It is defined by a pattern statement we created for the previous statement in the sequence). Input/output: NEW_TYPE - Output: a smaller type that we are trying to use. Input: if not NULL, it's the type of DEF. STMTS - additional pattern statements. If a pattern statement (type conversion) is created in this function, its original statement is added to STMTS. Output: OP0, OP1 - if the operation fits a smaller type, OP0 and OP1 are the new operands to use in the new pattern statement for STMT (will be created in vect_recog_over_widening_pattern ()). NEW_DEF_STMT - in case DEF has to be promoted, we create two pattern statements for STMT: the first one is a type promotion and the second one is the operation itself. We return the type promotion statement in NEW_DEF_STMT and further store it in STMT_VINFO_PATTERN_DEF_SEQ of the second pattern statement.
References build_nonstandard_integer_type(), compare_tree_int(), first, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_expr_type(), has_single_use(), int_fits_type_p(), is_gimple_assign(), make_ssa_name(), type(), type_conversion_p(), vect_same_loop_or_bb_p(), vect_supportable_shift(), and vinfo_for_stmt().
Referenced by vect_recog_over_widening_pattern().
void vect_pattern_recog | ( | ) |
Function vect_pattern_recog Input: LOOP_VINFO - a struct_loop_info of a loop in which we want to look for computation idioms. Output - for each computation idiom that is detected we create a new stmt that provides the same functionality and that can be vectorized. We also record some information in the struct_stmt_info of the relevant stmts, as explained below: At the entry to this function we have the following stmts, with the following initial value in the STMT_VINFO fields: stmt in_pattern_p related_stmt vec_stmt S1: a_i = .... - - - S2: a_2 = ..use(a_i).. - - - S3: a_1 = ..use(a_2).. - - - S4: a_0 = ..use(a_1).. - - - S5: ... = ..use(a_0).. - - - Say the sequence {S1,S2,S3,S4} was detected as a pattern that can be represented by a single stmt. We then: - create a new stmt S6 equivalent to the pattern (the stmt is not inserted into the code) - fill in the STMT_VINFO fields as follows: in_pattern_p related_stmt vec_stmt S1: a_i = .... - - - S2: a_2 = ..use(a_i).. - - - S3: a_1 = ..use(a_2).. - - - S4: a_0 = ..use(a_1).. true S6 - '---> S6: a_new = .... - S4 - S5: ... = ..use(a_0).. - - - (the last stmt in the pattern (S4) and the new pattern stmt (S6) point to each other through the RELATED_STMT field). S6 will be marked as relevant in vect_mark_stmts_to_be_vectorized instead of S4 because it will replace all its uses. Stmts {S1,S2,S3} will remain irrelevant unless used by stmts other than S4. If vectorization succeeds, vect_transform_stmt will skip over {S1,S2,S3} (because they are marked as irrelevant). It will vectorize S6, and record a pointer to the new vector stmt VS6 from S6 (as usual). S4 will be skipped, and S5 will be vectorized as usual: in_pattern_p related_stmt vec_stmt S1: a_i = .... - - - S2: a_2 = ..use(a_i).. - - - S3: a_1 = ..use(a_2).. - - - > VS6: va_new = .... - - - S4: a_0 = ..use(a_1).. true S6 VS6 '---> S6: a_new = .... - S4 VS6 > VS5: ... = ..vuse(va_new).. - - - S5: ... = ..use(a_0).. - - - DCE could then get rid of {S1,S2,S3,S4,S5} (if their defs are not used elsewhere), and we'll end up with: VS6: va_new = .... VS5: ... = ..vuse(va_new).. In case of more than one pattern statements, e.g., widen-mult with intermediate type: S1 a_t = ; S2 a_T = (TYPE) a_t; '--> S3: a_it = (interm_type) a_t; S4 prod_T = a_T * CONST; '--> S5: prod_T' = a_it w* CONST; there may be other users of a_T outside the pattern. In that case S2 will be marked as relevant (as well as S3), and both S2 and S3 will be analyzed and vectorized. The vector stmt VS2 will be recorded in S2, and VS3 will be recorded in S3.
References dump_enabled_p(), dump_printf_loc(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), loop::num_nodes, si, vect_location, vect_pattern_recog_1(), vect_vect_recog_func_ptrs, and vinfo_for_stmt().
Referenced by vect_analyze_loop_2(), and vect_slp_analyze_bb_1().
|
static |
Function vect_pattern_recog_1 Input: PATTERN_RECOG_FUNC: A pointer to a function that detects a certain computation pattern. STMT: A stmt from which the pattern search should start. If PATTERN_RECOG_FUNC successfully detected the pattern, it creates an expression that computes the same functionality and can be used to replace the sequence of stmts that are involved in the pattern. Output: This function checks if the expression returned by PATTERN_RECOG_FUNC is supported in vector form by the target. We use 'TYPE_IN' to obtain the relevant vector type. If 'TYPE_IN' is already a vector type, then this indicates that target support had already been checked by PATTERN_RECOG_FUNC. If 'TYPE_OUT' is also returned by PATTERN_RECOG_FUNC, we check that it fits to the available target pattern. This function also does some bookkeeping, as explained in the documentation for vect_recog_pattern.
References dump_enabled_p(), dump_gimple_stmt(), dump_printf_loc(), get_vectype_for_scalar_type(), gimple_assign_rhs_code(), gsi_stmt(), insn_data, is_gimple_assign(), is_gimple_call(), loop::next, optab_default, optab_for_tree_code(), optab_handler(), vect_location, vect_mark_pattern_stmts(), and vinfo_for_stmt().
Referenced by vect_pattern_recog().
|
static |
Function vect_recog_bool_pattern Try to find pattern like following: bool a_b, b_b, c_b, d_b, e_b; TYPE f_T; loop: S1 a_b = x1 CMP1 y1; S2 b_b = x2 CMP2 y2; S3 c_b = a_b & b_b; S4 d_b = x3 CMP3 y3; S5 e_b = c_b | d_b; S6 f_T = (TYPE) e_b; where type 'TYPE' is an integral type. Input: * LAST_STMT: A stmt at the end from which the pattern search begins, i.e. cast of a bool to an integer type. Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the pattern. Assuming size of TYPE is the same as size of all comparisons (otherwise some casts would be added where needed), the above sequence we create related pattern stmts: S1' a_T = x1 CMP1 y1 ? 1 : 0; S3' c_T = x2 CMP2 y2 ? a_T : 0; S4' d_T = x3 CMP3 y3 ? 1 : 0; S5' e_T = c_T | d_T; S6' f_T = e_T; Instead of the above S3' we could emit: S2' b_T = x2 CMP2 y2 ? 1 : 0; S3' c_T = a_T | b_T; but the above is more efficient.
References adjust_bool_pattern(), check_bool_pattern(), DR_STMT, dump_enabled_p(), dump_printf_loc(), get_vectype_for_scalar_type(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), is_gimple_assign(), last_stmt(), new_pattern_def_seq(), new_stmt_vec_info(), set_vinfo_for_stmt(), useless_type_conversion_p(), vect_location, vect_recog_temp_ssa_var(), and vinfo_for_stmt().
|
static |
Detect a signed division by a constant that wouldn't be otherwise vectorized: type a_t, b_t; S1 a_t = b_t / N; where type 'type' is an integral type and N is a constant. Similarly handle modulo by a constant: S4 a_t = b_t % N; Input/Output: * STMTS: Contains a stmt from which the pattern search begins, i.e. the division stmt. S1 is replaced by if N is a power of two constant and type is signed: S3 y_t = b_t < 0 ? N - 1 : 0; S2 x_t = b_t + y_t; S1' a_t = x_t >> log2 (N); S4 is replaced if N is a power of two constant and type is signed by (where *_T temporaries have unsigned type): S9 y_T = b_t < 0 ? -1U : 0U; S8 z_T = y_T >> (sizeof (type_t) * CHAR_BIT - log2 (N)); S7 z_t = (type) z_T; S6 w_t = b_t + z_t; S5 x_t = w_t & (N - 1); S4' a_t = x_t - z_t; Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the division S1 or modulo S4 stmt.
References append_pattern_def_seq(), build_int_cst(), build_nonstandard_integer_type(), can_mult_highpart_p(), choose_multiplier(), compare_tree_int(), dump_enabled_p(), dump_gimple_stmt(), dump_gimple_stmt_loc(), dump_printf_loc(), floor_log2(), get_vectype_for_scalar_type(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), HOST_BITS_PER_WIDE_INT, host_integerp(), HOST_WIDE_INT, integer_pow2p(), integer_zerop(), is_gimple_assign(), last_stmt(), new_pattern_def_seq(), new_stmt_vec_info(), optab_default, optab_for_tree_code(), optab_handler(), set_vinfo_for_stmt(), shift, tree_int_cst_sgn(), tree_log2(), tree_low_cst(), unknown_optab, vect_location, vect_recog_temp_ssa_var(), and vinfo_for_stmt().
|
static |
Function vect_recog_dot_prod_pattern Try to find the following pattern: type x_t, y_t; TYPE1 prod; TYPE2 sum = init; loop: sum_0 = phi <init, sum_1> S1 x_t = ... S2 y_t = ... S3 x_T = (TYPE1) x_t; S4 y_T = (TYPE1) y_t; S5 prod = x_T * y_T; [S6 prod = (TYPE2) prod; #optional] S7 sum_1 = prod + sum_0; where 'TYPE1' is exactly double the size of type 'type', and 'TYPE2' is the same size of 'TYPE1' or bigger. This is a special case of a reduction computation. Input: * STMTS: Contains a stmt from which the pattern search begins. In the example, when this function is called with S7, the pattern {S3,S4,S5,S6,S7} will be detected. Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the sequence of stmts that constitute the pattern. In this case it will be: WIDEN_DOT_PRODUCT <x_t, y_t, sum_0> Note: The dot-prod idiom is a widening reduction pattern that is vectorized without preserving all the intermediate results. It produces only N/2 (widened) results (by summing up pairs of intermediate results) rather than all N results. Therefore, we cannot allow this pattern when we want to get all the results and in the correct order (as is the case when this computation is in an inner-loop nested in an outer-loop that us being vectorized).
References dump_enabled_p(), dump_gimple_stmt(), dump_printf_loc(), flow_bb_inside_loop_p(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_expr_type(), is_gimple_assign(), last_stmt(), nested_in_vect_loop_p(), type(), type_conversion_p(), types_compatible_p(), vect_internal_def, vect_location, vect_recog_temp_ssa_var(), vect_reduction_def, and vinfo_for_stmt().
|
static |
Function vect_recog_mixed_size_cond_pattern Try to find the following pattern: type x_t, y_t; TYPE a_T, b_T, c_T; loop: S1 a_T = x_t CMP y_t ? b_T : c_T; where type 'TYPE' is an integral type which has different size from 'type'. b_T and c_T are either constants (and if 'TYPE' is wider than 'type', the constants need to fit into an integer type with the same width as 'type') or results of conversion from 'type'. Input: * LAST_STMT: A stmt from which the pattern search begins. Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the pattern. Additionally a def_stmt is added. a_it = x_t CMP y_t ? b_it : c_it; a_T = (TYPE) a_it;
References build_nonstandard_integer_type(), dump_enabled_p(), dump_printf_loc(), expand_vec_cond_expr_p(), get_vectype_for_scalar_type(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_expr_type(), int_fits_type_p(), is_gimple_assign(), last_stmt(), new_pattern_def_seq(), new_stmt_vec_info(), set_vinfo_for_stmt(), type(), type_conversion_p(), types_compatible_p(), unshare_expr(), vect_internal_def, vect_location, vect_recog_temp_ssa_var(), and vinfo_for_stmt().
|
static |
Try to find a statement or a sequence of statements that can be performed on a smaller type: type x_t; TYPE x_T, res0_T, res1_T; loop: S1 x_t = *p; S2 x_T = (TYPE) x_t; S3 res0_T = op (x_T, C0); S4 res1_T = op (res0_T, C1); S5 ... = () res1_T; - type demotion where type 'TYPE' is at least double the size of type 'type', C0 and C1 are constants. Check if S3 and S4 can be done on a smaller type than 'TYPE', it can either be 'type' or some intermediate type. For now, we expect S5 to be a type demotion operation. We also check that S3 and S4 have only one use.
References dump_enabled_p(), dump_gimple_stmt(), dump_printf_loc(), first, get_vectype_for_scalar_type(), gimple_assign_lhs(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_expr_type(), is_gimple_assign(), make_ssa_name(), new_pattern_def_seq(), vect_location, vect_operation_fits_smaller_type(), vect_recog_temp_ssa_var(), vect_single_imm_use(), and vinfo_for_stmt().
|
static |
Function vect_recog_pow_pattern Try to find the following pattern: x = POW (y, N); with POW being one of pow, powf, powi, powif and N being either 2 or 0.5. Input: * LAST_STMT: A stmt from which the pattern search begins. Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the sequence of stmts that constitute the pattern. In this case it will be: x = x * x or x = sqrt (x)
References BUILT_IN_NORMAL, dconst2, dconsthalf, exp(), get_vectype_for_scalar_type(), gimple_build_assign_with_ops(), gimple_build_call(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_set_lhs(), host_integerp(), is_gimple_call(), last_stmt(), mathfn_built_in(), tree_low_cst(), vect_recog_temp_ssa_var(), and vectorizable_function().
|
static |
Detect a rotate pattern wouldn't be otherwise vectorized: type a_t, b_t, c_t; S0 a_t = b_t r<< c_t; Input/Output: * STMTS: Contains a stmt from which the pattern search begins, i.e. the shift/rotate stmt. The original stmt (S0) is replaced with a sequence: S1 d_t = -c_t; S2 e_t = d_t & (B - 1); S3 f_t = b_t << c_t; S4 g_t = b_t >> e_t; S0 a_t = f_t | g_t; where B is element bitsize of type. Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the rotate S0 stmt.
References append_pattern_def_seq(), build_int_cst(), CDI_DOMINATORS, edge_def::dest, dominated_by_p(), dump_enabled_p(), dump_gimple_stmt_loc(), dump_printf_loc(), get_vectype_for_scalar_type(), gimple_assign_cast_p(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_bb(), gimple_build_assign_with_ops(), gsi_insert_on_edge_immediate(), host_integerp(), HOST_WIDE_INT, integer_zerop(), is_gimple_assign(), last_stmt(), loop_preheader_edge(), new_stmt_vec_info(), optab_for_tree_code(), optab_handler(), optab_scalar, optab_vector, set_vinfo_for_stmt(), tree_low_cst(), type(), vect_constant_def, vect_external_def, vect_internal_def, vect_is_simple_use(), vect_location, vect_recog_temp_ssa_var(), and vinfo_for_stmt().
|
static |
Helper to return a new temporary for pattern of TYPE for STMT. If STMT is NULL, the caller must set SSA_NAME_DEF_STMT for the returned SSA var.
References make_temp_ssa_name().
Referenced by adjust_bool_pattern(), adjust_bool_pattern_cast(), vect_recog_bool_pattern(), vect_recog_divmod_pattern(), vect_recog_dot_prod_pattern(), vect_recog_mixed_size_cond_pattern(), vect_recog_over_widening_pattern(), vect_recog_pow_pattern(), vect_recog_rotate_pattern(), vect_recog_vector_vector_shift_pattern(), vect_recog_widen_mult_pattern(), vect_recog_widen_shift_pattern(), and vect_recog_widen_sum_pattern().
|
static |
Detect a vector by vector shift pattern that wouldn't be otherwise vectorized: type a_t; TYPE b_T, res_T; S1 a_t = ; S2 b_T = ; S3 res_T = b_T op a_t; where type 'TYPE' is a type with different size than 'type', and op is <<, >> or rotate. Also detect cases: type a_t; TYPE b_T, c_T, res_T; S0 c_T = ; S1 a_t = (type) c_T; S2 b_T = ; S3 res_T = b_T op a_t; Input/Output: * STMTS: Contains a stmt from which the pattern search begins, i.e. the shift/rotate stmt. The original stmt (S3) is replaced with a shift/rotate which has same type on both operands, in the second case just b_T op c_T, in the first case with added cast from a_t to c_T in STMT_VINFO_PATTERN_DEF_SEQ. Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the shift/rotate S3 stmt.
References dump_enabled_p(), dump_gimple_stmt_loc(), dump_printf_loc(), get_vectype_for_scalar_type(), gimple_assign_cast_p(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), is_gimple_assign(), last_stmt(), new_pattern_def_seq(), vect_internal_def, vect_is_simple_use(), vect_location, vect_recog_temp_ssa_var(), and vinfo_for_stmt().
|
static |
Function vect_recog_widen_mult_pattern Try to find the following pattern: type a_t, b_t; TYPE a_T, b_T, prod_T; S1 a_t = ; S2 b_t = ; S3 a_T = (TYPE) a_t; S4 b_T = (TYPE) b_t; S5 prod_T = a_T * b_T; where type 'TYPE' is at least double the size of type 'type'. Also detect unsigned cases: unsigned type a_t, b_t; unsigned TYPE u_prod_T; TYPE a_T, b_T, prod_T; S1 a_t = ; S2 b_t = ; S3 a_T = (TYPE) a_t; S4 b_T = (TYPE) b_t; S5 prod_T = a_T * b_T; S6 u_prod_T = (unsigned TYPE) prod_T; and multiplication by constants: type a_t; TYPE a_T, prod_T; S1 a_t = ; S3 a_T = (TYPE) a_t; S5 prod_T = a_T * CONST; A special case of multiplication by constants is when 'TYPE' is 4 times bigger than 'type', but CONST fits an intermediate type 2 times smaller than 'TYPE'. In that case we create an additional pattern stmt for S3 to create a variable of the intermediate type, and perform widen-mult on the intermediate type as well: type a_t; interm_type a_it; TYPE a_T, prod_T, prod_T'; S1 a_t = ; S3 a_T = (TYPE) a_t; '--> a_it = (interm_type) a_t; S5 prod_T = a_T * CONST; '--> prod_T' = a_it w* CONST; Input/Output: * STMTS: Contains a stmt from which the pattern search begins. In the example, when this function is called with S5, the pattern {S3,S4,S5,(S6)} is detected. In case of unsigned widen-mult, the original stmt (S5) is replaced with S6 in STMTS. In case of multiplication by a constant of an intermediate type (the last case above), STMTS also contains S3 (inserted before S5). Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the sequence of stmts that constitute the pattern. In this case it will be: WIDEN_MULT <a_t, b_t>
References dump_enabled_p(), dump_gimple_stmt_loc(), dump_printf_loc(), get_vectype_for_scalar_type(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_expr_type(), is_gimple_assign(), last_stmt(), supportable_widening_operation(), type(), type_conversion_p(), types_compatible_p(), vect_handle_widen_op_by_const(), vect_location, vect_recog_temp_ssa_var(), and vect_single_imm_use().
|
static |
Detect widening shift pattern: type a_t; TYPE a_T, res_T; S1 a_t = ; S2 a_T = (TYPE) a_t; S3 res_T = a_T << CONST; where type 'TYPE' is at least double the size of type 'type'. Also detect cases where the shift result is immediately converted to another type 'result_type' that is no larger in size than 'TYPE'. In those cases we perform a widen-shift that directly results in 'result_type', to avoid a possible over-widening situation: type a_t; TYPE a_T, res_T; result_type res_result; S1 a_t = ; S2 a_T = (TYPE) a_t; S3 res_T = a_T << CONST; S4 res_result = (result_type) res_T; '--> res_result' = a_t w<< CONST; And a case when 'TYPE' is 4 times bigger than 'type'. In that case we create an additional pattern stmt for S2 to create a variable of an intermediate type, and perform widen-shift on the intermediate type: type a_t; interm_type a_it; TYPE a_T, res_T, res_T'; S1 a_t = ; S2 a_T = (TYPE) a_t; '--> a_it = (interm_type) a_t; S3 res_T = a_T << CONST; '--> res_T' = a_it <<* CONST; Input/Output: * STMTS: Contains a stmt from which the pattern search begins. In case of unsigned widen-shift, the original stmt (S3) is replaced with S4 in STMTS. When an intermediate type is used and a pattern statement is created for S2, we also put S2 here (before S3). Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the sequence of stmts that constitute the pattern. In this case it will be: WIDEN_LSHIFT_EXPR <a_t, CONST>.
References dump_enabled_p(), dump_gimple_stmt_loc(), dump_printf_loc(), get_vectype_for_scalar_type(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_expr_type(), is_gimple_assign(), last_stmt(), supportable_widening_operation(), tree_int_cst_compare(), type(), type_conversion_p(), vect_handle_widen_op_by_const(), vect_location, vect_recog_temp_ssa_var(), vect_single_imm_use(), and vinfo_for_stmt().
|
static |
@verbatim Analysis Utilities for Loop Vectorization.
Copyright (C) 2006-2013 Free Software Foundation, Inc. Contributed by Dorit Nuzman dorit @il. ibm.c om
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
Pattern recognition functions
Function vect_recog_widen_sum_pattern Try to find the following pattern: type x_t; TYPE x_T, sum = init; loop: sum_0 = phi <init, sum_1> S1 x_t = *p; S2 x_T = (TYPE) x_t; S3 sum_1 = x_T + sum_0; where type 'TYPE' is at least double the size of type 'type', i.e - we're summing elements of type 'type' into an accumulator of type 'TYPE'. This is a special case of a reduction computation. Input: * LAST_STMT: A stmt from which the pattern search begins. In the example, when this function is called with S3, the pattern {S2,S3} will be detected. Output: * TYPE_IN: The type of the input arguments to the pattern. * TYPE_OUT: The type of the output of this pattern. * Return value: A new stmt that will be used to replace the sequence of stmts that constitute the pattern. In this case it will be: WIDEN_SUM <x_t, sum_0> Note: The widening-sum idiom is a widening reduction pattern that is vectorized without preserving all the intermediate results. It produces only N/2 (widened) results (by summing up pairs of intermediate results) rather than all N results. Therefore, we cannot allow this pattern when we want to get all the results and in the correct order (as is the case when this computation is in an inner-loop nested in an outer-loop that us being vectorized).
References dump_enabled_p(), dump_gimple_stmt(), dump_printf_loc(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_build_assign_with_ops(), gimple_expr_type(), is_gimple_assign(), last_stmt(), nested_in_vect_loop_p(), type(), type_conversion_p(), types_compatible_p(), vect_location, vect_recog_temp_ssa_var(), vect_reduction_def, and vinfo_for_stmt().
|
static |
Check whether STMT2 is in the same loop or basic block as STMT1. Which of the two applies depends on whether we're currently doing loop-based or basic-block-based vectorization, as determined by the vinfo_for_stmt for STMT1 (which must be defined). If this returns true, vinfo_for_stmt for STMT2 is guaranteed to be defined as well.
References flow_bb_inside_loop_p(), and vinfo_for_stmt().
Referenced by vect_handle_widen_op_by_const(), vect_operation_fits_smaller_type(), and vect_single_imm_use().
|
static |
If the LHS of DEF_STMT has a single use, and that statement is in the same loop or basic block, return it.
References gimple_assign_lhs(), single_imm_use(), and vect_same_loop_or_bb_p().
Referenced by vect_recog_over_widening_pattern(), vect_recog_widen_mult_pattern(), and vect_recog_widen_shift_pattern().
|
static |
Referenced by vect_pattern_recog().