Check alignment for no peeling gaps handling
authorKewen Lin <linkw@gcc.gnu.org>
Thu, 7 May 2020 17:52:52 +0000 (13:52 -0400)
committerJeff Law <law@torsion.usersys.redhat.com>
Thu, 7 May 2020 17:52:52 +0000 (13:52 -0400)
        * gcc/tree-vect-stmts.c (vectorizable_load): Check alignment to avoid
        redundant half vector handlings for no peeling gaps.

gcc/ChangeLog
gcc/tree-vect-stmts.c

index 176b0de434a5fb287d3d6963d9c5ae4eded48536..986da64ff8d289e547f643b3ccbacce7eeb04608 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-07  Kewen Lin  <linkw@gcc.gnu.org>
+
+       * tree-vect-stmts.c (vectorizable_load): Check alignment to avoid
+       redundant half vector handlings for no peeling gaps.
+
 2020-05-07  Giuliano Belinassi  <giuliano.belinassi@usp.br>
 
        * tree-ssa-operands.c (operands_scanner): New class.
index 38285871de63ca1db5b10fdf7b2e3e2d7f4e5da6..2349d3172063a3716946d0ac99eb38e03a89c282 100644 (file)
@@ -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