This is the mail archive of the 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]

[autovect] [patch] reduction related enhancements/fixes

This patch includes:

1) Reduction enhancements/fixes:

- We neglected to mark phis that are used in the loop by relevant/live
stmts as relevant/live as appropriate. This is important in order to detect
reduction that is used in the loop, and which is therefore not
vectorizable. The new testcase vect-noreduc.c is an example for such a

- It's wrong to record the out-of-loop use of the reduction-variable,
because by the time we get to using it loop peeling may have taken place
which creates new BBs between our loop and the out-of-lop use we had
recorded in the field STMT_VINFO_EXTERNAL_USE. This field is removed by
this patch, and we find the relevant use using immediate-uses info. This
fix allows us to vectorized reduction when peeling takes place. As a result
testcase vect-reduc-3.c now gets vectorized.

- Reorganize a bit the code that handles reduction to make it more uniform
with the handling of other types of computations (these are the changes in
vect_get_vec_def_for_operand, get_initial_def_for_reduction and

- Handle reductions when the reduction variable is not the last argument
(e.g., previously we could handle only 'sum=a[i]+sum'; with this patch we
can also handle 'sum=sum+a[i]').

2) Other cleanups:

- Remove 'ifdef ENABLE_CHECKING' wrappers around gcc_asserts.
- When checking the dependence distance, check for 'distance % VF == 0'
(instead of 'distance == 0') and for 'abs (distance) > VF' (instead of
'distance > VF').

Bootstrapped and tested on powerpc-apple-darwin, committed to



        * tree-vect-analyze.c (vect_analyze_operations): Fail vectorization
        in case of a relevant phi.
        (vect_analyze_data_ref_dependence): Check if distance modulo VF is
        zero. Check if absolute distance is greater than 0. Updated debug
        printouts accordingly.
        (vect_mark_relevant): Phis may be marked as relevant.
        (vect_mark_stmts_to_be_vectorized): Last use of a reduction does
        mark its defining phi as relevant. Update documentation
        (vect_pattern_recog_1): Remove setting of STMT_VINFO_EXTERNAL_USE.
        (vect_can_advance_ivs_p): Skip reduction phis.
        * tree-vect-transform.c (vect_get_vec_def_for_operand): Takes
        additional argument. Reduction is handled inside the switch. Return
        vector def instead of a scalar def for reduction by calling
        get_initial_def_for_reduction. The scalar_def is returned in the
        (vectorizable_target_reduction_pattern, vectorizable_reduction)
        (vectorizable_assignment, vectorizable_operation,
        (vectorizable_select): Update call to vect_get_vec_def_for_operand.
        (get_initial_def_for_reduction): Last argument changed from bool*
        tree*. Second argument name changed to init_val. Move
        (vect_create_epilog_for_reduction): Update call to
        vect_get_vec_def_for_operand. Call to get_initial_def_for_reduction
        moved to vect_get_vec_def_for_operand. Remove ifdef
        Remove use of STMT_VINFO_EXTERNAL_USE, find immediate uses instead.
        (vect_update_ivs_after_vectorizer): Skip reduction phis.
        * tree-vectorizer.h (after_loop_use): Field removed from
        (STMT_VINFO_EXTERNAL_USE): Macro removed.

        * tree-vect-analyze.c (vect_determine_vectorization_factor)
        (vect_analyze_operations, vect_enhance_data_refs_alignment)
        (vect_stmt_relevant_p): Remove ENABLE_CHECKING guard around
        * tree-vect-transform (vect_finish_stmt_generation)
        (vectorizable_reduction, vectorizable_target_reduction_pattern)
        (vectorizable_target_reduction_pattern, vectorizable_assignment)
        (vectorizable_operation, vectorizable_select, vect_transform_loop)
        (vect_do_peeling_for_loop_bound, vect_do_peeling_for_alignment):
        ENABLE_CHECKING guard around gcc_assert.
        (vect_create_cond_for_align_checks): Replace an abort with a
        * tree-vectorizer.c (slpeel_update_phi_nodes_for_guard1)
        (new_stmt_vec_info): Remove setting of STMT_VINFO_EXTERNAL_USE.
        (vect_is_simple_use): Update documentation.
        (reduction_code_for_scalar_code): Update documentation. Swap
        if needed.
        * tree-vect-transform.c (vect_get_new_vect_var): Remove redundant
        * tree.def: Fix typo.


(See attached file: autovect.june10)

Attachment: autovect.june10
Description: Binary data

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