Commit 89fa689a by Richard Sandiford Committed by Richard Sandiford

[38/46] Use dr_vec_info to represent a data reference

This patch makes various routines (mostly in tree-vect-data-refs.c)
take dr_vec_infos rather than data_references.  The affected routines
are really dealing with the way that an access is going to vectorised,
rather than with the original scalar access described by the
data_reference.

2018-07-31  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vectorizer.h (set_dr_misalignment, dr_misalignment)
	(DR_TARGET_ALIGNMENT, aligned_access_p, known_alignment_for_access_p)
	(vect_known_alignment_in_bytes, vect_dr_behavior)
	(vect_get_scalar_dr_size): Take references as dr_vec_infos
	instead of data_references.  Update calls to other routines for
	which the same change has been made.
	* tree-vect-data-refs.c (vect_preserves_scalar_order_p): Take
	dr_vec_infos instead of stmt_vec_infos.
	(vect_analyze_data_ref_dependence): Update call accordingly.
	(vect_slp_analyze_data_ref_dependence)
	(vect_record_base_alignments): Use DR_VECT_AUX.
	(vect_calculate_target_alignment, vect_compute_data_ref_alignment)
	(vect_update_misalignment_for_peel, verify_data_ref_alignment)
	(vector_alignment_reachable_p, vect_get_data_access_cost)
	(vect_peeling_supportable, vect_analyze_group_access_1)
	(vect_analyze_group_access, vect_analyze_data_ref_access)
	(vect_vfa_segment_size, vect_vfa_access_size, vect_vfa_align)
	(vect_compile_time_alias, vect_small_gap_p)
	(vectorizable_with_step_bound_p, vect_duplicate_ssa_name_ptr_info):
	(vect_supportable_dr_alignment): Take references as dr_vec_infos
	instead of data_references.  Update calls to other routines for
	which the same change has been made.
	(vect_verify_datarefs_alignment, vect_get_peeling_costs_all_drs)
	(vect_find_same_alignment_drs, vect_analyze_data_refs_alignment)
	(vect_slp_analyze_and_verify_node_alignment)
	(vect_analyze_data_ref_accesses, vect_prune_runtime_alias_test_list)
	(vect_create_addr_base_for_vector_ref, vect_create_data_ref_ptr)
	(vect_setup_realignment): Use dr_vec_infos.  Update calls after
	above changes.
	(_vect_peel_info::dr): Replace with...
	(_vect_peel_info::dr_info): ...this new field.
	(vect_peeling_hash_get_most_frequent)
	(vect_peeling_hash_choose_best_peeling): Update accordingly.
	(vect_peeling_hash_get_lowest_cost):
	(vect_enhance_data_refs_alignment): Likewise.  Update calls to other
	routines for which the same change has been made.
	(vect_peeling_hash_insert): Likewise.  Take a dr_vec_info instead of a
	data_reference.
	* tree-vect-loop-manip.c (get_misalign_in_elems)
	(vect_gen_prolog_loop_niters): Use dr_vec_infos.  Update calls after
	above changes.
	* tree-vect-loop.c (vect_analyze_loop_2): Likewise.
	* tree-vect-stmts.c (vect_get_store_cost, vect_get_load_cost)
	(vect_truncate_gather_scatter_offset, compare_step_with_zero)
	(get_group_load_store_type, get_negative_load_store_type)
	(vect_get_data_ptr_increment, vectorizable_store)
	(vectorizable_load): Likewise.
	(ensure_base_align): Take a dr_vec_info instead of a data_reference.
	Update calls to other routines for which the same change has been made.

From-SVN: r263153
parent f44fb7aa
2018-07-31 Richard Sandiford <richard.sandiford@arm.com> 2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
* tree-vectorizer.h (set_dr_misalignment, dr_misalignment)
(DR_TARGET_ALIGNMENT, aligned_access_p, known_alignment_for_access_p)
(vect_known_alignment_in_bytes, vect_dr_behavior)
(vect_get_scalar_dr_size): Take references as dr_vec_infos
instead of data_references. Update calls to other routines for
which the same change has been made.
* tree-vect-data-refs.c (vect_preserves_scalar_order_p): Take
dr_vec_infos instead of stmt_vec_infos.
(vect_analyze_data_ref_dependence): Update call accordingly.
(vect_slp_analyze_data_ref_dependence)
(vect_record_base_alignments): Use DR_VECT_AUX.
(vect_calculate_target_alignment, vect_compute_data_ref_alignment)
(vect_update_misalignment_for_peel, verify_data_ref_alignment)
(vector_alignment_reachable_p, vect_get_data_access_cost)
(vect_peeling_supportable, vect_analyze_group_access_1)
(vect_analyze_group_access, vect_analyze_data_ref_access)
(vect_vfa_segment_size, vect_vfa_access_size, vect_vfa_align)
(vect_compile_time_alias, vect_small_gap_p)
(vectorizable_with_step_bound_p, vect_duplicate_ssa_name_ptr_info):
(vect_supportable_dr_alignment): Take references as dr_vec_infos
instead of data_references. Update calls to other routines for
which the same change has been made.
(vect_verify_datarefs_alignment, vect_get_peeling_costs_all_drs)
(vect_find_same_alignment_drs, vect_analyze_data_refs_alignment)
(vect_slp_analyze_and_verify_node_alignment)
(vect_analyze_data_ref_accesses, vect_prune_runtime_alias_test_list)
(vect_create_addr_base_for_vector_ref, vect_create_data_ref_ptr)
(vect_setup_realignment): Use dr_vec_infos. Update calls after
above changes.
(_vect_peel_info::dr): Replace with...
(_vect_peel_info::dr_info): ...this new field.
(vect_peeling_hash_get_most_frequent)
(vect_peeling_hash_choose_best_peeling): Update accordingly.
(vect_peeling_hash_get_lowest_cost):
(vect_enhance_data_refs_alignment): Likewise. Update calls to other
routines for which the same change has been made.
(vect_peeling_hash_insert): Likewise. Take a dr_vec_info instead of a
data_reference.
* tree-vect-loop-manip.c (get_misalign_in_elems)
(vect_gen_prolog_loop_niters): Use dr_vec_infos. Update calls after
above changes.
* tree-vect-loop.c (vect_analyze_loop_2): Likewise.
* tree-vect-stmts.c (vect_get_store_cost, vect_get_load_cost)
(vect_truncate_gather_scatter_offset, compare_step_with_zero)
(get_group_load_store_type, get_negative_load_store_type)
(vect_get_data_ptr_increment, vectorizable_store)
(vectorizable_load): Likewise.
(ensure_base_align): Take a dr_vec_info instead of a data_reference.
Update calls to other routines for which the same change has been made.
2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
* tree-vectorizer.h (vec_info::move_dr): New member function. * tree-vectorizer.h (vec_info::move_dr): New member function.
(dataref_aux): Rename to... (dataref_aux): Rename to...
(dr_vec_info): ...this and add "dr" and "stmt" fields. (dr_vec_info): ...this and add "dr" and "stmt" fields.
......
...@@ -1560,14 +1560,15 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo, ...@@ -1560,14 +1560,15 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo,
static tree static tree
get_misalign_in_elems (gimple **seq, loop_vec_info loop_vinfo) get_misalign_in_elems (gimple **seq, loop_vec_info loop_vinfo)
{ {
struct data_reference *dr = LOOP_VINFO_UNALIGNED_DR (loop_vinfo); dr_vec_info *dr_info = DR_VECT_AUX (LOOP_VINFO_UNALIGNED_DR (loop_vinfo));
stmt_vec_info stmt_info = vect_dr_stmt (dr); stmt_vec_info stmt_info = dr_info->stmt;
tree vectype = STMT_VINFO_VECTYPE (stmt_info); tree vectype = STMT_VINFO_VECTYPE (stmt_info);
unsigned int target_align = DR_TARGET_ALIGNMENT (dr); unsigned int target_align = DR_TARGET_ALIGNMENT (dr_info);
gcc_assert (target_align != 0); gcc_assert (target_align != 0);
bool negative = tree_int_cst_compare (DR_STEP (dr), size_zero_node) < 0; bool negative = tree_int_cst_compare (DR_STEP (dr_info->dr),
size_zero_node) < 0;
tree offset = (negative tree offset = (negative
? size_int (-TYPE_VECTOR_SUBPARTS (vectype) + 1) ? size_int (-TYPE_VECTOR_SUBPARTS (vectype) + 1)
: size_zero_node); : size_zero_node);
...@@ -1626,14 +1627,14 @@ static tree ...@@ -1626,14 +1627,14 @@ static tree
vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo, vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo,
basic_block bb, int *bound) basic_block bb, int *bound)
{ {
struct data_reference *dr = LOOP_VINFO_UNALIGNED_DR (loop_vinfo); dr_vec_info *dr_info = DR_VECT_AUX (LOOP_VINFO_UNALIGNED_DR (loop_vinfo));
tree var; tree var;
tree niters_type = TREE_TYPE (LOOP_VINFO_NITERS (loop_vinfo)); tree niters_type = TREE_TYPE (LOOP_VINFO_NITERS (loop_vinfo));
gimple_seq stmts = NULL, new_stmts = NULL; gimple_seq stmts = NULL, new_stmts = NULL;
tree iters, iters_name; tree iters, iters_name;
stmt_vec_info stmt_info = vect_dr_stmt (dr); stmt_vec_info stmt_info = dr_info->stmt;
tree vectype = STMT_VINFO_VECTYPE (stmt_info); tree vectype = STMT_VINFO_VECTYPE (stmt_info);
unsigned int target_align = DR_TARGET_ALIGNMENT (dr); unsigned int target_align = DR_TARGET_ALIGNMENT (dr_info);
if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) > 0) if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) > 0)
{ {
...@@ -1658,7 +1659,8 @@ vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo, ...@@ -1658,7 +1659,8 @@ vect_gen_prolog_loop_niters (loop_vec_info loop_vinfo,
/* Create: (niters_type) ((align_in_elems - misalign_in_elems) /* Create: (niters_type) ((align_in_elems - misalign_in_elems)
& (align_in_elems - 1)). */ & (align_in_elems - 1)). */
bool negative = tree_int_cst_compare (DR_STEP (dr), size_zero_node) < 0; bool negative = tree_int_cst_compare (DR_STEP (dr_info->dr),
size_zero_node) < 0;
if (negative) if (negative)
iters = fold_build2 (MINUS_EXPR, type, misalign_in_elems, iters = fold_build2 (MINUS_EXPR, type, misalign_in_elems,
align_in_elems_tree); align_in_elems_tree);
......
...@@ -2142,8 +2142,9 @@ start_over: ...@@ -2142,8 +2142,9 @@ start_over:
/* Niters for peeled prolog loop. */ /* Niters for peeled prolog loop. */
if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0) if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0)
{ {
struct data_reference *dr = LOOP_VINFO_UNALIGNED_DR (loop_vinfo); dr_vec_info *dr_info
tree vectype = STMT_VINFO_VECTYPE (vect_dr_stmt (dr)); = DR_VECT_AUX (LOOP_VINFO_UNALIGNED_DR (loop_vinfo));
tree vectype = STMT_VINFO_VECTYPE (dr_info->stmt);
niters_th += TYPE_VECTOR_SUBPARTS (vectype) - 1; niters_th += TYPE_VECTOR_SUBPARTS (vectype) - 1;
} }
else else
......
...@@ -1294,15 +1294,15 @@ vect_dr_stmt (data_reference *dr) ...@@ -1294,15 +1294,15 @@ vect_dr_stmt (data_reference *dr)
#define DR_MISALIGNMENT_UNINITIALIZED (-2) #define DR_MISALIGNMENT_UNINITIALIZED (-2)
inline void inline void
set_dr_misalignment (struct data_reference *dr, int val) set_dr_misalignment (dr_vec_info *dr_info, int val)
{ {
DR_VECT_AUX (dr)->misalignment = val; dr_info->misalignment = val;
} }
inline int inline int
dr_misalignment (struct data_reference *dr) dr_misalignment (dr_vec_info *dr_info)
{ {
int misalign = DR_VECT_AUX (dr)->misalignment; int misalign = dr_info->misalignment;
gcc_assert (misalign != DR_MISALIGNMENT_UNINITIALIZED); gcc_assert (misalign != DR_MISALIGNMENT_UNINITIALIZED);
return misalign; return misalign;
} }
...@@ -1313,52 +1313,51 @@ dr_misalignment (struct data_reference *dr) ...@@ -1313,52 +1313,51 @@ dr_misalignment (struct data_reference *dr)
#define SET_DR_MISALIGNMENT(DR, VAL) set_dr_misalignment (DR, VAL) #define SET_DR_MISALIGNMENT(DR, VAL) set_dr_misalignment (DR, VAL)
/* Only defined once DR_MISALIGNMENT is defined. */ /* Only defined once DR_MISALIGNMENT is defined. */
#define DR_TARGET_ALIGNMENT(DR) DR_VECT_AUX (DR)->target_alignment #define DR_TARGET_ALIGNMENT(DR) ((DR)->target_alignment)
/* Return true if data access DR is aligned to its target alignment /* Return true if data access DR_INFO is aligned to its target alignment
(which may be less than a full vector). */ (which may be less than a full vector). */
static inline bool static inline bool
aligned_access_p (struct data_reference *data_ref_info) aligned_access_p (dr_vec_info *dr_info)
{ {
return (DR_MISALIGNMENT (data_ref_info) == 0); return (DR_MISALIGNMENT (dr_info) == 0);
} }
/* Return TRUE if the alignment of the data access is known, and FALSE /* Return TRUE if the alignment of the data access is known, and FALSE
otherwise. */ otherwise. */
static inline bool static inline bool
known_alignment_for_access_p (struct data_reference *data_ref_info) known_alignment_for_access_p (dr_vec_info *dr_info)
{ {
return (DR_MISALIGNMENT (data_ref_info) != DR_MISALIGNMENT_UNKNOWN); return (DR_MISALIGNMENT (dr_info) != DR_MISALIGNMENT_UNKNOWN);
} }
/* Return the minimum alignment in bytes that the vectorized version /* Return the minimum alignment in bytes that the vectorized version
of DR is guaranteed to have. */ of DR_INFO is guaranteed to have. */
static inline unsigned int static inline unsigned int
vect_known_alignment_in_bytes (struct data_reference *dr) vect_known_alignment_in_bytes (dr_vec_info *dr_info)
{ {
if (DR_MISALIGNMENT (dr) == DR_MISALIGNMENT_UNKNOWN) if (DR_MISALIGNMENT (dr_info) == DR_MISALIGNMENT_UNKNOWN)
return TYPE_ALIGN_UNIT (TREE_TYPE (DR_REF (dr))); return TYPE_ALIGN_UNIT (TREE_TYPE (DR_REF (dr_info->dr)));
if (DR_MISALIGNMENT (dr) == 0) if (DR_MISALIGNMENT (dr_info) == 0)
return DR_TARGET_ALIGNMENT (dr); return DR_TARGET_ALIGNMENT (dr_info);
return DR_MISALIGNMENT (dr) & -DR_MISALIGNMENT (dr); return DR_MISALIGNMENT (dr_info) & -DR_MISALIGNMENT (dr_info);
} }
/* Return the behavior of DR with respect to the vectorization context /* Return the behavior of DR_INFO with respect to the vectorization context
(which for outer loop vectorization might not be the behavior recorded (which for outer loop vectorization might not be the behavior recorded
in DR itself). */ in DR_INFO itself). */
static inline innermost_loop_behavior * static inline innermost_loop_behavior *
vect_dr_behavior (data_reference *dr) vect_dr_behavior (dr_vec_info *dr_info)
{ {
gimple *stmt = DR_STMT (dr); stmt_vec_info stmt_info = dr_info->stmt;
stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
if (loop_vinfo == NULL if (loop_vinfo == NULL
|| !nested_in_vect_loop_p (LOOP_VINFO_LOOP (loop_vinfo), stmt_info)) || !nested_in_vect_loop_p (LOOP_VINFO_LOOP (loop_vinfo), stmt_info))
return &DR_INNERMOST (dr); return &DR_INNERMOST (dr_info->dr);
else else
return &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info); return &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info);
} }
...@@ -1451,17 +1450,17 @@ vect_max_vf (loop_vec_info loop_vinfo) ...@@ -1451,17 +1450,17 @@ vect_max_vf (loop_vec_info loop_vinfo)
return MAX_VECTORIZATION_FACTOR; return MAX_VECTORIZATION_FACTOR;
} }
/* Return the size of the value accessed by unvectorized data reference DR. /* Return the size of the value accessed by unvectorized data reference
This is only valid once STMT_VINFO_VECTYPE has been calculated for the DR_INFO. This is only valid once STMT_VINFO_VECTYPE has been calculated
associated gimple statement, since that guarantees that DR accesses for the associated gimple statement, since that guarantees that DR_INFO
either a scalar or a scalar equivalent. ("Scalar equivalent" here accesses either a scalar or a scalar equivalent. ("Scalar equivalent"
includes things like V1SI, which can be vectorized in the same way here includes things like V1SI, which can be vectorized in the same way
as a plain SI.) */ as a plain SI.) */
inline unsigned int inline unsigned int
vect_get_scalar_dr_size (struct data_reference *dr) vect_get_scalar_dr_size (dr_vec_info *dr_info)
{ {
return tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr)))); return tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_info->dr))));
} }
/* Source location + hotness information. */ /* Source location + hotness information. */
...@@ -1561,7 +1560,7 @@ extern tree vect_get_mask_type_for_stmt (stmt_vec_info); ...@@ -1561,7 +1560,7 @@ extern tree vect_get_mask_type_for_stmt (stmt_vec_info);
/* In tree-vect-data-refs.c. */ /* In tree-vect-data-refs.c. */
extern bool vect_can_force_dr_alignment_p (const_tree, unsigned int); extern bool vect_can_force_dr_alignment_p (const_tree, unsigned int);
extern enum dr_alignment_support vect_supportable_dr_alignment extern enum dr_alignment_support vect_supportable_dr_alignment
(struct data_reference *, bool); (dr_vec_info *, bool);
extern tree vect_get_smallest_scalar_type (stmt_vec_info, HOST_WIDE_INT *, extern tree vect_get_smallest_scalar_type (stmt_vec_info, HOST_WIDE_INT *,
HOST_WIDE_INT *); HOST_WIDE_INT *);
extern bool vect_analyze_data_ref_dependences (loop_vec_info, unsigned int *); extern bool vect_analyze_data_ref_dependences (loop_vec_info, unsigned int *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment