]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Another fix for single-element permutes (PR 84265)
authorRichard Sandiford <richard.sandiford@linaro.org>
Thu, 8 Feb 2018 15:17:20 +0000 (15:17 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 8 Feb 2018 15:17:20 +0000 (15:17 +0000)
PR83753 was about a case in which we ended up trying to "vectorise"
a group of loads ore stores using single-element vectors.  The problem
was that we were classifying the load or store as VMAT_CONTIGUOUS_PERMUTE
rather than VMAT_CONTIGUOUS, even though it doesn't make sense to permute
a single-element vector.

In that PR it was enough to change get_group_load_store_type,
because vectorisation ended up being unprofitable and so we didn't
take things further.  But when vectorisation is profitable, the same
fix is needed in vectorizable_load and vectorizable_store.

2018-02-08  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
PR tree-optimization/84265
* tree-vect-stmts.c (vectorizable_store): Don't treat
VMAT_CONTIGUOUS accesses as grouped.
(vectorizable_load): Likewise.

gcc/testsuite/
PR tree-optimization/84265
* gcc.dg/vect/pr84265.c: New test.

From-SVN: r257492

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr84265.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 0e8b23288a0d8d7f7a06a3c952746a70572c3a81..d9c45c9e794927841357b25bd9526478bd4e567b 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-08  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       PR tree-optimization/84265
+       * tree-vect-stmts.c (vectorizable_store): Don't treat
+       VMAT_CONTIGUOUS accesses as grouped.
+       (vectorizable_load): Likewise.
+
 2018-02-08  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR tree-optimization/81635
index 52cf0b53870a1e78f89ba18a2362d42594b867dc..e989c94a5e4f8ec5df44d9962e2c85c11fa6769d 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-08  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       PR tree-optimization/84265
+       * gcc.dg/vect/pr84265.c: New test.
+
 2018-02-08  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR tree-optimization/81635
diff --git a/gcc/testsuite/gcc.dg/vect/pr84265.c b/gcc/testsuite/gcc.dg/vect/pr84265.c
new file mode 100644 (file)
index 0000000..59984ae
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+struct a
+{
+  unsigned long b;
+  unsigned long c;
+  int d;
+  int *e;
+  char f;
+};
+
+struct
+{
+  int g;
+  struct a h[];
+} i;
+
+int j, k;
+void l ()
+{
+  for (; k; k++)
+    j += (int) (i.h[k].c - i.h[k].b);
+}
index c5085ca9c0ae54c093f55bac42e781170ea02a6f..6066a52c23e2dd95ff86b7de110aeee785f7e70d 100644 (file)
@@ -6214,7 +6214,8 @@ vectorizable_store (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
     }
 
   grouped_store = (STMT_VINFO_GROUPED_ACCESS (stmt_info)
-                  && memory_access_type != VMAT_GATHER_SCATTER);
+                  && memory_access_type != VMAT_GATHER_SCATTER
+                  && (slp || memory_access_type != VMAT_CONTIGUOUS));
   if (grouped_store)
     {
       first_stmt = GROUP_FIRST_ELEMENT (stmt_info);
@@ -7708,7 +7709,8 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt,
       return true;
     }
 
-  if (memory_access_type == VMAT_GATHER_SCATTER)
+  if (memory_access_type == VMAT_GATHER_SCATTER
+      || (!slp && memory_access_type == VMAT_CONTIGUOUS))
     grouped_load = false;
 
   if (grouped_load)