Currently we force peeling for gaps whenever element overrun can occur
but for aligned accesses we know that the loads won't trap and thus
we can avoid this.

Bootstrap and regtest running on x86_64-unknown-linux-gnu (I expect
some testsuite fallout here so didn't bother to invent a new testcase).

Just in case somebody thinks the overrun is a bad idea in general
(even when not trapping).  Like for ASAN or valgrind.

Richard.

2016-11-07  Richard Biener  <rguent...@suse.de>

        * tree-vect-stmts.c (get_group_load_store_type): If the
        access is aligned do not trigger peeling for gaps.

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c       (revision 241893)
+++ gcc/tree-vect-stmts.c       (working copy)
@@ -1770,6 +1771,11 @@ get_group_load_store_type (gimple *stmt,
                               " non-consecutive accesses\n");
              return false;
            }
+         /* If the access is aligned an overrun is fine.  */
+         if (overrun_p
+             && aligned_access_p
+                  (STMT_VINFO_DATA_REF (vinfo_for_stmt (first_stmt))))
+           overrun_p = false;
          if (overrun_p && !can_overrun_p)
            {
              if (dump_enabled_p ())
@@ -1789,6 +1795,10 @@ get_group_load_store_type (gimple *stmt,
       /* If there is a gap at the end of the group then these optimizations
         would access excess elements in the last iteration.  */
       bool would_overrun_p = (gap != 0);
+      /* If the access is aligned an overrun is fine.  */
+      if (would_overrun_p
+         && aligned_access_p (STMT_VINFO_DATA_REF (stmt_info)))
+       would_overrun_p = false;
       if (!STMT_VINFO_STRIDED_P (stmt_info)
          && (can_overrun_p || !would_overrun_p)
          && compare_step_with_zero (stmt) > 0)

Reply via email to