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]

[autovect] [patch] prep step towards supporting reduction





This patch prepares the grounds for the following enhancements:
1. support vectorization of reduction (e.g. for (i=0;i<n;i++) { s += a[i];
})
2. support vectorization of induction (e.g. for (i=0;i<n;i++) { a[i] = i;
})
3. support vectorization in the presence of values defined in the loop and
used after the loop

Main changes:
- new field STMT_VINFO_DEF_TYPE in stmt_vec_info, used to record what kind
of computation a stmt performs. Phi nodes would typically compute something
that will be classified as induction or reduction, and other stmts in the
loop would be typically clssified as "in-loop" computation (i.e. a regular
computation that has no dependencies across loop iterations).
- new field STMT_VINFO_LIVE_P in stmt_vec_info, used to mark if a def of a
stmt is used after the loop. "relevant" indicates if a stmt needs to be
vectorized. A stmt can be classified as one or the other or both. We
currently don't support anything that is used out side the loop unless it
is loop invariant.
- phi nodes now also have a stmt_vec_info, because (1) we want to record
what kind of computation is involved in the def-use cycle that this phi is
part of (e.g. a form of reduction, or induction), and (2) we want to record
if the value that a phi node defines is used after the loop. (With this
patch we don't yet detect reductions, so anything that isn't an induction
we consider an unknown pattern).

Bootstrapped (with vectorization) and tested on powerpc-darwin

dorit

        * tree-vectorizer.h (vect_def_type): New enum definition.
        (_stmt_vec_info): New fields "live"  and "def_type" added.
        (STMT_VINFO_LIVE_P, STMT_VINFO_DEF_TYPE): New macros to access
above
        new fields.
        (set_stmt_info): Argument type changed to tree_ann_t.
        (vinfo_for_stmt): Type of variable "ann" changed to tree_ann_t.
        * tree-vectorizer.c (vect_analyze_scalar_cycles): Function made
void
        instead of bool. Set STMT_VINFO_DEF_TYPE for phi nodes.
        (vect_is_simple_use): Takes additional arguments. Consider
        STMT_VINFO_DEF_TYPE.
        (vect_mark_relevant): Takes additional arguments. Set
STMT_VINFO_LIVE_P.
        (vect_stmt_relevant_p): Takes additional arguments.
        (new_stmt_vec_info): Initialize the new fields STMT_VINFO_LIVE_P
and
        STMT_VINFO_DEF_TYPE.
        (new_loop_vec_info): Set a stmt_vec_info for phi node.
        (destroy_loop_vec_info): Free the stmt_vec_info for phi nodes.
        (vect_get_vec_def_for_operand): Use new outputs of
vect_is_simple_use.
        (vectorizable_assignment): Use new API for vect_is_simple_use.
        Support the case when the def of the assignment is used out of the
loop
        and the use of the assignment is invariant.
        (vectorizable_operation): Use new API for vect_is_simple_use. Check
        if the def of the operation is used out side the loop.
        (vectorizable_load): Likewise.
        (vectorizable_select) Likewise.
        (vectorizable_store): Use new API for vect_is_simple_use.
        (vect_is_simple_cond): Use new API for vect_is_simple_use.
        (vect_analyze_operations): Check if operations are used after the
loop.
        Also check phi nodes.
        (vect_enhance_data_refs_alignment): Call vect_can_advance_ivs_p.
        (vect_mark_stmts_to_be_vectorized): Check vect_stmt_relevant_p also
for
        phis when initializing the worklist. Use new API for
vect_mark_relevant
        ans vect_stmt_relevant_p. Use new API for vect_is_simple_use. Mark
        "liveness" (i.e. presence of uses after loop) seperately from
        "relevance" (i.e. need to be vectorized).
        (vect_analyze_loop): Call to vect_analyze_scalar_cycles moved
earlier.
        (vect_pattern_recog_1): Cast to tree_ann_t in call to
set_stmt_info.
        (vect_transform_loop): Likewise.
        (vect_update_ivs_after_vectorizer): Add debug printouts.
        (vect_can_advance_ivs_p): Likewise.

(See attached file: feb12)

Attachment: feb12
Description: Binary data


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