From 20bdc473ebd7176544e0c8cdf87750adc6f44a97 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 22 Sep 2017 16:26:43 +0000 Subject: [PATCH] Add a vect_get_scalar_dr_size helper function This patch adds a helper function for getting the number of bytes accessed by an unvectorised data reference, which helps when general modes have a variable size. 2017-09-22 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-vectorizer.h (vect_get_scalar_dr_size): New function. * tree-vect-data-refs.c (vect_update_misalignment_for_peel): Use it. (vect_enhance_data_refs_alignment): Likewise. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r253099 --- gcc/ChangeLog | 8 ++++++++ gcc/tree-vect-data-refs.c | 11 ++++------- gcc/tree-vectorizer.h | 13 +++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bbef1ef490a..43e885b7614 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-09-22 Richard Sandiford + Alan Hayward + David Sherwood + + * tree-vectorizer.h (vect_get_scalar_dr_size): New function. + * tree-vect-data-refs.c (vect_update_misalignment_for_peel): Use it. + (vect_enhance_data_refs_alignment): Likewise. + 2017-09-22 Richard Earnshaw * config/arm/parsecpu.awk (fatal): Note that we've encountered an diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index cab2f2f935b..175052a290b 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -955,7 +955,6 @@ vect_compute_data_ref_alignment (struct data_reference *dr) return true; } - /* Function vect_update_misalignment_for_peel. Sets DR's misalignment - to 0 if it has the same alignment as DR_PEEL, @@ -975,8 +974,8 @@ vect_update_misalignment_for_peel (struct data_reference *dr, unsigned int i; vec same_aligned_drs; struct data_reference *current_dr; - int dr_size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr)))); - int dr_peel_size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr_peel)))); + int dr_size = vect_get_scalar_dr_size (dr); + int dr_peel_size = vect_get_scalar_dr_size (dr_peel); stmt_vec_info stmt_info = vinfo_for_stmt (DR_STMT (dr)); stmt_vec_info peel_stmt_info = vinfo_for_stmt (DR_STMT (dr_peel)); @@ -1664,8 +1663,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) vectype = STMT_VINFO_VECTYPE (stmt_info); nelements = TYPE_VECTOR_SUBPARTS (vectype); - mis = DR_MISALIGNMENT (dr) / GET_MODE_SIZE (TYPE_MODE ( - TREE_TYPE (DR_REF (dr)))); + mis = DR_MISALIGNMENT (dr) / vect_get_scalar_dr_size (dr); if (DR_MISALIGNMENT (dr) != 0) npeel_tmp = (negative ? (mis - nelements) : (nelements - mis)) & (nelements - 1); @@ -1937,8 +1935,7 @@ vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo) updating DR_MISALIGNMENT values. The peeling factor is the vectorization factor minus the misalignment as an element count. */ - mis = DR_MISALIGNMENT (dr0); - mis /= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr0)))); + mis = DR_MISALIGNMENT (dr0) / vect_get_scalar_dr_size (dr0); npeel = ((negative ? mis - nelements : nelements - mis) & (nelements - 1)); } diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index d6753ff4eea..5d273ca1a68 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1095,6 +1095,19 @@ vect_get_num_copies (loop_vec_info loop_vinfo, tree vectype) / TYPE_VECTOR_SUBPARTS (vectype)); } +/* Return the size of the value accessed by unvectorized data reference DR. + This is only valid once STMT_VINFO_VECTYPE has been calculated for the + associated gimple statement, since that guarantees that DR accesses + either a scalar or a scalar equivalent. ("Scalar equivalent" here + includes things like V1SI, which can be vectorized in the same way + as a plain SI.) */ + +inline unsigned int +vect_get_scalar_dr_size (struct data_reference *dr) +{ + return tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr)))); +} + /* Source location */ extern source_location vect_location; -- 2.30.2