The following fixes the 403.gcc build I broke with r265457.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

(vect testsuite and SPEC 2k6 is happy).

Richard.

>From 1ee436877c5d0dcb3dad6019c2e8d4570ded8e13 Mon Sep 17 00:00:00 2001
From: Richard Guenther <rguent...@suse.de>
Date: Thu, 25 Oct 2018 14:50:37 +0200
Subject: [PATCH] fix-pr87746

2018-10-25  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/87746
        * tree-vect-data-refs.c (vect_update_misalignment_for_peel):
        Simplify and fix WRT strided store groups with size not
        equal to step in element count.

        * gcc.dg/pr87746.c: New testcase.

diff --git a/gcc/testsuite/gcc.dg/pr87746.c b/gcc/testsuite/gcc.dg/pr87746.c
new file mode 100644
index 00000000000..74f076a9e5f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr87746.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+/* { dg-additional-options "-mavx2" { target x86_64-*-* i?86-*-* } } */
+
+typedef struct rtx_def *rtx;
+struct replacement {
+    rtx *where;
+    rtx *subreg_loc;
+    int mode;
+};
+static struct replacement replacements[150];
+void move_replacements (rtx *x, int y, int n_replacements)
+{
+  int i;
+  for (i = 0; i < n_replacements; i++)
+    if (replacements[i].subreg_loc == x)
+      replacements[i].subreg_loc = y;
+    else if (replacements[i].where == x) 
+      {
+       replacements[i].where = y;
+       replacements[i].subreg_loc = 0;
+      }
+}
diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 9185b1bd1c0..20ecbfb45b7 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -1010,20 +1010,10 @@ vect_update_misalignment_for_peel (dr_vec_info *dr_info,
   unsigned int i;
   vec<dr_p> same_aligned_drs;
   struct data_reference *current_dr;
-  int dr_size = vect_get_scalar_dr_size (dr_info);
-  int dr_peel_size = vect_get_scalar_dr_size (dr_peel_info);
-  stmt_vec_info stmt_info = dr_info->stmt;
   stmt_vec_info peel_stmt_info = dr_peel_info->stmt;
 
- /* For interleaved data accesses the step in the loop must be multiplied by
-     the size of the interleaving group.  */
-  if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
-    dr_size *= DR_GROUP_SIZE (DR_GROUP_FIRST_ELEMENT (stmt_info));
-  if (STMT_VINFO_GROUPED_ACCESS (peel_stmt_info))
-    dr_peel_size *= DR_GROUP_SIZE (peel_stmt_info);
-
-  /* It can be assumed that the data refs with the same alignment as dr_peel
-     are aligned in the vector loop.  */
+  /* It can be assumed that if dr_info has the same alignment as dr_peel,
+     it is aligned in the vector loop.  */
   same_aligned_drs = STMT_VINFO_SAME_ALIGN_REFS (peel_stmt_info);
   FOR_EACH_VEC_ELT (same_aligned_drs, i, current_dr)
     {
@@ -1031,8 +1021,8 @@ vect_update_misalignment_for_peel (dr_vec_info *dr_info,
         continue;
       gcc_assert (!known_alignment_for_access_p (dr_info)
                  || !known_alignment_for_access_p (dr_peel_info)
-                 || (DR_MISALIGNMENT (dr_info) / dr_size
-                     == DR_MISALIGNMENT (dr_peel_info) / dr_peel_size));
+                 || (DR_MISALIGNMENT (dr_info)
+                     == DR_MISALIGNMENT (dr_peel_info)));
       SET_DR_MISALIGNMENT (dr_info, 0);
       return;
     }
@@ -1040,10 +1030,8 @@ vect_update_misalignment_for_peel (dr_vec_info *dr_info,
   if (known_alignment_for_access_p (dr_info)
       && known_alignment_for_access_p (dr_peel_info))
     {
-      bool negative = tree_int_cst_compare (DR_STEP (dr_info->dr),
-                                           size_zero_node) < 0;
       int misal = DR_MISALIGNMENT (dr_info);
-      misal += negative ? -npeel * dr_size : npeel * dr_size;
+      misal += npeel * TREE_INT_CST_LOW (DR_STEP (dr_info->dr));
       misal &= DR_TARGET_ALIGNMENT (dr_info) - 1;
       SET_DR_MISALIGNMENT (dr_info, misal);
       return;
@@ -2559,11 +2547,22 @@ vect_analyze_group_access_1 (dr_vec_info *dr_info)
            dump_printf (MSG_NOTE, "strided store ");
          else
            dump_printf (MSG_NOTE, "store ");
-         dump_printf (MSG_NOTE, "of size %u starting with %G",
-                      (unsigned)groupsize, stmt_info->stmt);
+         dump_printf (MSG_NOTE, "of size %u\n",
+                      (unsigned)groupsize);
+         dump_printf_loc (MSG_NOTE, vect_location, "\t%G", stmt_info->stmt);
+         next = DR_GROUP_NEXT_ELEMENT (stmt_info);
+         while (next)
+           {
+             if (DR_GROUP_GAP (next) != 1)
+               dump_printf_loc (MSG_NOTE, vect_location,
+                                "\t<gap of %d elements>\n",
+                                DR_GROUP_GAP (next));
+             dump_printf_loc (MSG_NOTE, vect_location, "\t%G", next->stmt);
+             next = DR_GROUP_NEXT_ELEMENT (next);
+           }
          if (DR_GROUP_GAP (stmt_info) != 0)
            dump_printf_loc (MSG_NOTE, vect_location,
-                            "There is a gap of %u elements after the group\n",
+                            "\t<gap of %d elements>\n",
                             DR_GROUP_GAP (stmt_info));
        }
 

Reply via email to