This patch adds a helper function for getting the number of bytes accessed by a scalar data reference, which helps when general modes have a variable size.
Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. OK to install? Richard 2017-09-14 Richard Sandiford <richard.sandif...@linaro.org> Alan Hayward <alan.hayw...@arm.com> David Sherwood <david.sherw...@arm.com> gcc/ * tree-vect-data-refs.c (vect_get_dr_size): New function. (vect_update_misalignment_for_peel): Use it. (vect_enhance_data_refs_alignment): Likewise. Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2017-09-14 11:27:50.350257085 +0100 +++ gcc/tree-vect-data-refs.c 2017-09-14 11:29:19.649870912 +0100 @@ -950,6 +950,13 @@ vect_compute_data_ref_alignment (struct return true; } +/* Return the size of the value accessed by DR, which is always constant. */ + +static unsigned int +vect_get_dr_size (struct data_reference *dr) +{ + return GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (DR_REF (dr)))); +} /* Function vect_update_misalignment_for_peel. Sets DR's misalignment @@ -970,8 +977,8 @@ vect_update_misalignment_for_peel (struc unsigned int i; vec<dr_p> 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_dr_size (dr); + int dr_peel_size = vect_get_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)); @@ -1659,8 +1666,7 @@ vect_enhance_data_refs_alignment (loop_v 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_dr_size (dr); if (DR_MISALIGNMENT (dr) != 0) npeel_tmp = (negative ? (mis - nelements) : (nelements - mis)) & (nelements - 1); @@ -1932,8 +1938,7 @@ vect_enhance_data_refs_alignment (loop_v 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_dr_size (dr0); npeel = ((negative ? mis - nelements : nelements - mis) & (nelements - 1)); }