From b0f64919e44ffca149e29f0225c3e810b98901c1 Mon Sep 17 00:00:00 2001 From: irar Date: Thu, 3 Nov 2011 08:44:35 +0000 Subject: PR tree-optimization/50912 * tree-vectorizer.h (slp_void_p): New. (struct _slp_tree): Replace left and right with children. Update documentation. (struct _slp_oprnd_info): New. (vect_get_vec_defs): Declare. (vect_get_slp_defs): Update arguments. * tree-vect-loop.c (vect_create_epilog_for_reduction): Call vect_get_vec_defs instead of vect_get_slp_defs. (vectorizable_reduction): Likewise. * tree-vect-stmts.c (vect_get_vec_defs): Remove static, add argument. Update call to vect_get_slp_defs. (vectorizable_conversion): Update call to vect_get_vec_defs. (vectorizable_assignment, vectorizable_shift, vectorizable_operation): Likewise. (vectorizable_type_demotion): Call vect_get_vec_defs instead of vect_get_slp_defs. (vectorizable_type_promotion, vectorizable_store): Likewise. (vect_analyze_stmt): Fix typo. * tree-vect-slp.c (vect_free_slp_tree): Update SLP tree traversal. (vect_print_slp_tree, vect_mark_slp_stmts, vect_mark_slp_stmts_relevant, vect_slp_rearrange_stmts, vect_detect_hybrid_slp_stmts, vect_slp_analyze_node_operations, vect_schedule_slp_instance): Likewise. (vect_create_new_slp_node): New. (vect_create_oprnd_info, vect_free_oprnd_info): Likewise. (vect_get_and_check_slp_defs): Pass information about defs using oprnds_info, allow any number of operands. (vect_build_slp_tree): Likewise. Update calls to vect_get_and_check_slp_defs. Fix comments. (vect_analyze_slp_instance): Move node creation to vect_create_new_slp_node. (vect_get_slp_defs): Allow any number of operands. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180819 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-vectorizer.h | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'gcc/tree-vectorizer.h') diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 6703edb5ee0..bcbc32cbd95 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -73,15 +73,15 @@ enum vect_def_type { /************************************************************************ SLP ************************************************************************/ +typedef void *slp_void_p; +DEF_VEC_P (slp_void_p); +DEF_VEC_ALLOC_P (slp_void_p, heap); -/* A computation tree of an SLP instance. Each node corresponds to a group of +/* A computation tree of an SLP instance. Each node corresponds to a group of stmts to be packed in a SIMD stmt. */ typedef struct _slp_tree { - /* Only binary and unary operations are supported. LEFT child corresponds to - the first operand and RIGHT child to the second if the operation is - binary. */ - struct _slp_tree *left; - struct _slp_tree *right; + /* Nodes that contain def-stmts of this node statements operands. */ + VEC (slp_void_p, heap) *children; /* A group of scalar stmts to be vectorized together. */ VEC (gimple, heap) *stmts; /* Vectorized stmt/s. */ @@ -146,14 +146,32 @@ DEF_VEC_ALLOC_P(slp_instance, heap); #define SLP_INSTANCE_LOADS(S) (S)->loads #define SLP_INSTANCE_FIRST_LOAD_STMT(S) (S)->first_load -#define SLP_TREE_LEFT(S) (S)->left -#define SLP_TREE_RIGHT(S) (S)->right +#define SLP_TREE_CHILDREN(S) (S)->children #define SLP_TREE_SCALAR_STMTS(S) (S)->stmts #define SLP_TREE_VEC_STMTS(S) (S)->vec_stmts #define SLP_TREE_NUMBER_OF_VEC_STMTS(S) (S)->vec_stmts_size #define SLP_TREE_OUTSIDE_OF_LOOP_COST(S) (S)->cost.outside_of_loop #define SLP_TREE_INSIDE_OF_LOOP_COST(S) (S)->cost.inside_of_loop +/* This structure is used in creation of an SLP tree. Each instance + corresponds to the same operand in a group of scalar stmts in an SLP + node. */ +typedef struct _slp_oprnd_info +{ + /* Def-stmts for the operands. */ + VEC (gimple, heap) *def_stmts; + /* Information about the first statement, its vector def-type, type, the + operand itself in case it's constant, and an indication if it's a pattern + stmt. */ + enum vect_def_type first_dt; + tree first_def_type; + tree first_const_oprnd; + bool first_pattern; +} *slp_oprnd_info; + +DEF_VEC_P(slp_oprnd_info); +DEF_VEC_ALLOC_P(slp_oprnd_info, heap); + typedef struct _vect_peel_info { @@ -824,6 +842,8 @@ extern void vect_get_load_cost (struct data_reference *, int, bool, unsigned int *, unsigned int *); extern void vect_get_store_cost (struct data_reference *, int, unsigned int *); extern bool vect_supportable_shift (enum tree_code, tree); +extern void vect_get_vec_defs (tree, tree, gimple, VEC (tree, heap) **, + VEC (tree, heap) **, slp_tree, int); /* In tree-vect-data-refs.c. */ extern bool vect_can_force_dr_alignment_p (const_tree, unsigned int); @@ -891,8 +911,9 @@ extern void vect_update_slp_costs_according_to_vf (loop_vec_info); extern bool vect_analyze_slp (loop_vec_info, bb_vec_info); extern bool vect_make_slp_decision (loop_vec_info); extern void vect_detect_hybrid_slp (loop_vec_info); -extern void vect_get_slp_defs (tree, tree, slp_tree, VEC (tree,heap) **, - VEC (tree,heap) **, int); +extern void vect_get_slp_defs (VEC (tree, heap) *, slp_tree, + VEC (slp_void_p, heap) **, int); + extern LOC find_bb_location (basic_block); extern bb_vec_info vect_slp_analyze_bb (basic_block); extern void vect_slp_transform_bb (basic_block); -- cgit v1.2.1 From f2104a5407d5a8d2fac30d7c306f571632a344dc Mon Sep 17 00:00:00 2001 From: irar Date: Sun, 6 Nov 2011 09:01:45 +0000 Subject: * tree-vectorizer.h (vectorizable_condition): Add argument. * tree-vect-loop.c (vectorizable_reduction): Fail for condition in SLP. Update calls to vectorizable_condition. * tree-vect-stmts.c (vect_is_simple_cond): Add basic block info to the arguments. Pass it to vect_is_simple_use_1. (vectorizable_condition): Add slp_node to the arguments. Support vectorization of basic blocks. Fail for reduction in SLP. Update calls to vect_is_simple_cond and vect_is_simple_use. Support SLP: call vect_get_slp_defs to get vector operands. (vect_analyze_stmt): Update calls to vectorizable_condition. (vect_transform_stmt): Likewise. * tree-vect-slp.c (vect_create_new_slp_node): Handle COND_EXPR. (vect_get_and_check_slp_defs): Handle COND_EXPR. Allow pattern def stmts. (vect_build_slp_tree): Handle COND_EXPR. (vect_analyze_slp_instance): Push pattern statements to root node. (vect_get_constant_vectors): Fix comments. Handle COND_EXPR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181026 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-vectorizer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-vectorizer.h') diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index bcbc32cbd95..1d61d9d9af2 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -837,7 +837,7 @@ extern bool vect_transform_stmt (gimple, gimple_stmt_iterator *, extern void vect_remove_stores (gimple); extern bool vect_analyze_stmt (gimple, bool *, slp_tree); extern bool vectorizable_condition (gimple, gimple_stmt_iterator *, gimple *, - tree, int); + tree, int, slp_tree); extern void vect_get_load_cost (struct data_reference *, int, bool, unsigned int *, unsigned int *); extern void vect_get_store_cost (struct data_reference *, int, unsigned int *); -- cgit v1.2.1 From 16dfb11221da8bb69bfcc5ca457cb6a6f145b03a Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 7 Nov 2011 15:59:07 +0000 Subject: PR tree-optimization/50789 * tree-vect-stmts.c (process_use): Add force argument, avoid exist_non_indexing_operands_for_use_p check if true. (vect_mark_stmts_to_be_vectorized): Adjust callers. Handle STMT_VINFO_GATHER_P. (gen_perm_mask): New function. (perm_mask_for_reverse): Use it. (reverse_vec_element): Rename to... (permute_vec_elements): ... this. Add Y and MASK_VEC arguments, generalize for any permutations. (vectorizable_load): Adjust caller. Handle STMT_VINFO_GATHER_P. * target.def (TARGET_VECTORIZE_BUILTIN_GATHER): New hook. * doc/tm.texi.in (TARGET_VECTORIZE_BUILTIN_GATHER): Document it. * doc/tm.texi: Regenerate. * tree-data-ref.c (initialize_data_dependence_relation, compute_self_dependence): No longer static. * tree-data-ref.h (initialize_data_dependence_relation, compute_self_dependence): New prototypes. * tree-vect-data-refs.c (vect_check_gather): New function. (vect_analyze_data_refs): Detect possible gather load data refs. * tree-vectorizer.h (struct _stmt_vec_info): Add gather_p field. (STMT_VINFO_GATHER_P): Define. (vect_check_gather): New prototype. * config/i386/i386-builtin-types.def: Add types for alternate gather builtins. * config/i386/sse.md (AVXMODE48P_DI): Remove. (VEC_GATHER_MODE): Rename mode_attr to... (VEC_GATHER_IDXSI): ... this. (VEC_GATHER_IDXDI, VEC_GATHER_SRCDI): New mode_attrs. (avx2_gathersi, *avx2_gathersi): Use instead of . (avx2_gatherdi): Use instead of < and instead of VEC_GATHER_MODE on src and mask operands. (*avx2_gatherdi): Likewise. Use VEC_GATHER_MODE iterator instead of AVXMODE48P_DI. (avx2_gatherdi256, *avx2_gatherdi256): Removed. * config/i386/i386.c (enum ix86_builtins): Add IX86_BUILTIN_GATHERALTSIV4DF, IX86_BUILTIN_GATHERALTDIV8SF, IX86_BUILTIN_GATHERALTSIV4DI and IX86_BUILTIN_GATHERALTDIV8SI. (ix86_init_mmx_sse_builtins): Create those builtins. (ix86_expand_builtin): Handle those builtins and adjust expansions of other gather builtins. (ix86_vectorize_builtin_gather): New function. (TARGET_VECTORIZE_BUILTIN_GATHER): Define. * gcc.target/i386/avx2-gather-1.c: New test. * gcc.target/i386/avx2-gather-2.c: New test. * gcc.target/i386/avx2-gather-3.c: New test. * gcc.target/i386/avx2-gather-4.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181089 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-vectorizer.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/tree-vectorizer.h') diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 1d61d9d9af2..927c0bd8cb5 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -535,6 +535,9 @@ typedef struct _stmt_vec_info { /* Is this statement vectorizable or should it be skipped in (partial) vectorization. */ bool vectorizable; + + /* For loads only, true if this is a gather load. */ + bool gather_p; } *stmt_vec_info; /* Access Functions. */ @@ -548,6 +551,7 @@ typedef struct _stmt_vec_info { #define STMT_VINFO_VEC_STMT(S) (S)->vectorized_stmt #define STMT_VINFO_VECTORIZABLE(S) (S)->vectorizable #define STMT_VINFO_DATA_REF(S) (S)->data_ref_info +#define STMT_VINFO_GATHER_P(S) (S)->gather_p #define STMT_VINFO_DR_BASE_ADDRESS(S) (S)->dr_base_address #define STMT_VINFO_DR_INIT(S) (S)->dr_init @@ -858,6 +862,8 @@ extern bool vect_analyze_data_refs_alignment (loop_vec_info, bb_vec_info); extern bool vect_verify_datarefs_alignment (loop_vec_info, bb_vec_info); extern bool vect_analyze_data_ref_accesses (loop_vec_info, bb_vec_info); extern bool vect_prune_runtime_alias_test_list (loop_vec_info); +extern tree vect_check_gather (gimple, loop_vec_info, tree *, tree *, + int *); extern bool vect_analyze_data_refs (loop_vec_info, bb_vec_info, int *); extern tree vect_create_data_ref_ptr (gimple, tree, struct loop *, tree, tree *, gimple_stmt_iterator *, -- cgit v1.2.1