tree-optimization/95916 - treat scalar ops explicitely
authorRichard Biener <rguenther@suse.de>
Mon, 29 Jun 2020 11:53:51 +0000 (13:53 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 29 Jun 2020 12:40:52 +0000 (14:40 +0200)
This explicitely treats the case of scalar operands for SLP
when computing insert locations.

2020-06-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/95916
* tree-vect-slp.c (vect_schedule_slp_instance): Explicitely handle
the case of not vectorized externals.

* gcc.dg/vect/pr95916.c: New testcase.

gcc/testsuite/gcc.dg/vect/pr95916.c [new file with mode: 0644]
gcc/tree-vect-slp.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr95916.c b/gcc/testsuite/gcc.dg/vect/pr95916.c
new file mode 100644 (file)
index 0000000..61b8ca3
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+extern short var_3, var_8;
+extern int var_5;
+extern char var_10;
+extern int arr_99[][16];
+void test()
+{
+  for (; 0 < var_10;)
+    for (long a = var_8;; a++)
+      arr_99[4][a] = var_3 << var_5;
+}
index b223956e3af494397f4efff4476e3e3e6f66f94d..1ffbf6f6af99df017a103617e4e3060c7913b495 100644 (file)
@@ -4293,6 +4293,21 @@ vect_schedule_slp_instance (vec_info *vinfo,
                  || vect_stmt_dominates_stmt_p (last_stmt, vstmt))
                last_stmt = vstmt;
          }
+       else if (!SLP_TREE_VECTYPE (child))
+         {
+           /* For externals we use unvectorized at all scalar defs.  */
+           unsigned j;
+           tree def;
+           FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_OPS (child), j, def)
+             if (TREE_CODE (def) == SSA_NAME
+                 && !SSA_NAME_IS_DEFAULT_DEF (def))
+               {
+                 gimple *stmt = SSA_NAME_DEF_STMT (def);
+                 if (!last_stmt
+                     || vect_stmt_dominates_stmt_p (last_stmt, stmt))
+                   last_stmt = stmt;
+               }
+         }
        else
          {
            /* For externals we have to look at all defs since their