]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/106196 - properly update virtual SSA for vector stores
authorRichard Biener <rguenther@suse.de>
Tue, 5 Jul 2022 08:43:42 +0000 (10:43 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 5 Jul 2022 10:55:32 +0000 (12:55 +0200)
The following properly handles aggregate returns of the const marked
STORE_LANES internal function to update virtual SSA form on-the-fly
rather than relying on a costly virtual SSA rewrite.

PR tree-optimization/106196
* tree-vect-stmts.cc (vect_finish_stmt_generation): Properly
handle aggregate returns of calls for VDEF updates.

* gcc.dg/torture/pr106196.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr106196.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr106196.c b/gcc/testsuite/gcc.dg/torture/pr106196.c
new file mode 100644 (file)
index 0000000..56723de
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize -fno-vect-cost-model" } */
+
+extern char a[];
+char *b;
+void e() {
+  char *d;
+  int c;
+  d = a;
+  for (; c; c++) {
+    d[2] = d[1] = d[0] = b[c];
+    d += 3;
+  }
+}
index 72107afc883649f96569816d099763a54f959ab0..3db6620dd4240b2304190de4e6339edb1c23f7f5 100644 (file)
@@ -1638,8 +1638,10 @@ vect_finish_stmt_generation (vec_info *vinfo,
              && ((is_gimple_assign (vec_stmt)
                   && !is_gimple_reg (gimple_assign_lhs (vec_stmt)))
                  || (is_gimple_call (vec_stmt)
-                     && !(gimple_call_flags (vec_stmt)
-                          & (ECF_CONST|ECF_PURE|ECF_NOVOPS)))))
+                     && (!(gimple_call_flags (vec_stmt)
+                           & (ECF_CONST|ECF_PURE|ECF_NOVOPS))
+                         || (gimple_call_lhs (vec_stmt)
+                             && !is_gimple_reg (gimple_call_lhs (vec_stmt)))))))
            {
              tree new_vdef = copy_ssa_name (vuse, vec_stmt);
              gimple_set_vdef (vec_stmt, new_vdef);