From 3807f286eff75cb0e4af924c3ee9e02add23e12e Mon Sep 17 00:00:00 2001 From: Kewen Lin Date: Thu, 7 May 2020 13:52:52 -0400 Subject: [PATCH] Check alignment for no peeling gaps handling * gcc/tree-vect-stmts.c (vectorizable_load): Check alignment to avoid redundant half vector handlings for no peeling gaps. --- gcc/ChangeLog | 5 +++++ gcc/tree-vect-stmts.c | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 176b0de434a..986da64ff8d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2020-05-07 Kewen Lin + + * tree-vect-stmts.c (vectorizable_load): Check alignment to avoid + redundant half vector handlings for no peeling gaps. + 2020-05-07 Giuliano Belinassi * tree-ssa-operands.c (operands_scanner): New class. diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 38285871de6..2349d317206 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9628,6 +9628,12 @@ vectorizable_load (vec_info *vinfo, { tree ltype = vectype; tree new_vtype = NULL_TREE; + unsigned HOST_WIDE_INT gap + = DR_GROUP_GAP (first_stmt_info); + unsigned int vect_align + = vect_known_alignment_in_bytes (first_dr_info); + unsigned int scalar_dr_size + = vect_get_scalar_dr_size (first_dr_info); /* If there's no peeling for gaps but we have a gap with slp loads then load the lower half of the vector only. See get_group_load_store_type for @@ -9635,11 +9641,10 @@ vectorizable_load (vec_info *vinfo, if (slp && loop_vinfo && !LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo) - && DR_GROUP_GAP (first_stmt_info) != 0 - && known_eq (nunits, - (group_size - - DR_GROUP_GAP (first_stmt_info)) * 2) - && known_eq (nunits, group_size)) + && gap != 0 + && known_eq (nunits, (group_size - gap) * 2) + && known_eq (nunits, group_size) + && gap >= (vect_align / scalar_dr_size)) { tree half_vtype; new_vtype @@ -9654,10 +9659,9 @@ vectorizable_load (vec_info *vinfo, if (ltype != vectype && memory_access_type == VMAT_CONTIGUOUS_REVERSE) { - unsigned HOST_WIDE_INT gap - = DR_GROUP_GAP (first_stmt_info); - gap *= tree_to_uhwi (TYPE_SIZE_UNIT (elem_type)); - tree gapcst = build_int_cst (ref_type, gap); + unsigned HOST_WIDE_INT gap_offset + = gap * tree_to_uhwi (TYPE_SIZE_UNIT (elem_type)); + tree gapcst = build_int_cst (ref_type, gap_offset); offset = size_binop (PLUS_EXPR, offset, gapcst); } data_ref -- 2.30.2