This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, vect] Support multiple types in SLP and generalize multi-step conversion


>
> Hi,
>
> This patch adds support of loops with multiple types in loop-aware SLP
and
> generalizes multi-step type conversions (for all types of vectorization).
>
> In order to support multiple types in an SLP instance, the number of
vector
> statements to be generated is now calculated for every SLP node according
> to the scalar type of the node statements, and the promotion/demotion
> operations take care of the transition between different data types.
>

Looks like this patch also makes SLP support idioms that have been
introduced by the vectorizer's pattern detection pass. cool!
(Also it's nice that there was very little logic required to make SLP
support multiple types (most of this patch is actually about the
non-SLP-specific part)).

> This patch also makes double step type conversion (
> http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00691.html) more general,
> allowing more than one intermediate step in conversion (e.g., conversion
> from long long to char). Since this part touches the same code as the
code
> for SLP (in vectorizable_type_demotion/promotion), I put it in the same
> patch.
>

thanks a lot for doing that! (and for addressing all the other comments (
http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00740.html))


> Is there a standard utility in GCC to compute pow? I didn't find any, so
I
> added vect_pow2 in tree-vectorizer.h...
>
> Bootstrapped with vectorization enabled and tested on vectorizer
testsuite
> on ppc-linux and x86-linux. Fully tested on x86-linux.
> O.K. for mainline?
>

yes. just a few very minor comments:

> +   - MULTI_STEP_CVT determines if the operation is a multi-step
conversion,
> +   like char->short->int - in that case MULTI_STEP_CVT will be 2. The
value of
> +   log2(multi_step_cvt) is the number of required steps.

please change "number of required steps" to "number of required
intermediate steps"


> +      /* We assume here that there will not be more than 4 steps in
> +         promotion sequence. We try three times to get to
NARROW_VECTYPE,
> +         and fail if we do not.  */
> +      *interm_types = VEC_alloc (tree, heap, 3);
> +      for (i = 0; i < 3; i++)
> +        {

please use a parameter instead of 3 - maybe MAX_INTERM_CVT_STEPS or
something like that.

(both of the above appear twice.)


> +/* Get vectorized definitions for loop-based vectorization. For the
first
> +   operand we call vect_get_vec_def_for_operand(), and for the rest we
get
> +   a copy with vect_get_vec_def_for_stmt_copy(). See
> +   vect_get_vec_def_for_stmt_copy() for details.  */
> +
> +static void
> +vect_get_loop_based_defs (tree *oprnd, gimple stmt, enum vect_def_type
dt,
> +                          VEC (tree, heap) **vec_oprnds, int
multi_step_cvt)
> +{

please add a short description of the inputs and outputs (e.g. so it would
be clear from the documentation that what this function does is collect all
the relevant defs into a VEC).

thanks,
dorit

> Thanks,
> Ira
>
> ChangeLog:
>
>       * tree-vectorizer.c (supportable_widening_operation): Support
>       multi-step conversion, return the number of steps in such
conversion
>       and the required intermediate types.
>       (supportable_narrowing_operation): Likewise.
>       * tree-vectorizer.h (vect_pow2): New function.
>       (supportable_widening_operation): Change argument types.
>       (supportable_narrowing_operation): Likewise.
>       (vectorizable_type_promotion): Add an argument.
>       (vectorizable_type_demotion): Likewise.
>       * tree-vect-analyze.c (vect_analyze_operations): Call
>       vectorizable_type_promotion and vectorizable_type_demotion with
>       additional argument.
>       (vect_get_and_check_slp_defs): Detect patterns.
>       (vect_build_slp_tree): Add an argument, don't fail in case of
> multiple
>       types.
>       (vect_analyze_slp_instance): Don't fail in case of multiple types.
> Call
>       vect_build_slp_tree with correct arguments. Calculate unrolling
> factor
>       according to the smallest type in the loop.
>       (vect_detect_hybrid_slp_stmts): Include statements from patterns.
>       * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Call
>       supportable_widening_operation with correct arguments.
>       * tree-vect-transform.c (vect_get_slp_defs): Add new argument, use
it
>       to allocate output vector operands lists.
>       (vect_get_vec_defs): Add new argument, pass it to
vect_get_slp_defs.
>       (vect_gen_widened_results_half): Remove unused argument.
>       (vectorizable_conversion): Call supportable_widening_operation,
>       supportable_narrowing_operation, vect_get_vec_defs, and
>       vect_gen_widened_results_half with correct arguments.
>       (vectorizable_assignment): Change documentation, support multiple
>       types in SLP, call vect_get_vec_defs with correct arguments.
>       (vectorizable_operation): Likewise.
>       (vect_get_loop_based_defs): New function.
>       (vect_create_vectorized_demotion_stmts): Likewise.
>       (vectorizable_type_demotion): Support loop-aware SLP and general
>       multi-step conversion. Call vect_get_loop_based_defs and
>       vect_create_vectorized_demotion_stmts for transformation.
>       (vect_create_vectorized_promotion_stmts): New function.
>       (vectorizable_type_promotion): Support loop-aware SLP and general
>       multi-step conversion. Call vect_create_vectorized_promotion_stmts
>       for transformation.
>       (vectorizable_store): Change documentation, support multiple
>       types in SLP, call vect_get_vec_defs with correct arguments.
>       (vectorizable_load): Likewise.
>       (vect_transform_stmt): Pass SLP_NODE to
>       vectorizable_type_promotion and vectorizable_type_demotion..
>       (vect_schedule_slp_instance): Move here the calculation of number
>       of vectorized statements for each node from...
>       (vect_schedule_slp): ... here.
>       (vect_transform_loop): Call vect_schedule_slp without the last
>       argument.
>
> testsuite/ChangeLog:
>
>       * gcc.dg/vect/slp-multitypes-1.c: New testcase.
>       * gcc.dg/vect/slp-multitypes-2.c, gcc.dg/vect/slp-multitypes-3.c,
>       gcc.dg/vect/slp-multitypes-4.c, gcc.dg/vect/slp-multitypes-5.c,
>       gcc.dg/vect/slp-multitypes-6.c, gcc.dg/vect/slp-multitypes-7.c,
>       gcc.dg/vect/slp-multitypes-8.c, gcc.dg/vect/slp-multitypes-9.c,
>       gcc.dg/vect/slp-multitypes-10.c, gcc.dg/vect/slp-multitypes-11.c,
>       gcc.dg/vect/slp-multitypes-12.c, gcc.dg/vect/slp-widen-mult-u8.c,
>       gcc.dg/vect/slp-widen-mult-s16.c,
gcc.dg/vect/vect-multitypes-16.c,.
>       gcc.dg/vect/vect-multitypes-17.c: Likewise.
>       * gcc.dg/vect/slp-9.c: Now vectorizable using SLP.
>       * gcc.dg/vect/slp-14.c, gcc.dg/vect/slp-5.c: Likewise.
>       * lib/target-supports.exp (check_effective_target_vect_long_long):
> New.
>
> (See attached file: slp-multi-types.txt)(See attached file: tests.
> txt)[attachment "slp-multi-types.txt" deleted by Dorit
> Nuzman/Haifa/IBM] [attachment "tests.txt" deleted by Dorit
Nuzman/Haifa/IBM]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]