The following fixes the vectorizer to properly deal with STRING_CSTs
now appearing more often.

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

Richard.

2019-06-24  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/90972
        * tree-vect-stmts.c (vect_init_vector): Handle CONSTANT_CLASS_P
        in common code, dealing with STRING_CST properly.

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

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c       (revision 272545)
+++ gcc/tree-vect-stmts.c       (working copy)
@@ -1481,20 +1481,19 @@ vect_init_vector (stmt_vec_info stmt_inf
                  val = new_temp;
                }
            }
-         else if (CONSTANT_CLASS_P (val))
-           val = fold_convert (TREE_TYPE (type), val);
          else
            {
-             new_temp = make_ssa_name (TREE_TYPE (type));
+             gimple_seq stmts = NULL;
              if (! INTEGRAL_TYPE_P (TREE_TYPE (val)))
-               init_stmt = gimple_build_assign (new_temp,
-                                                fold_build1 (VIEW_CONVERT_EXPR,
-                                                             TREE_TYPE (type),
-                                                             val));
+               val = gimple_build (&stmts, VIEW_CONVERT_EXPR,
+                                   TREE_TYPE (type), val);
              else
-               init_stmt = gimple_build_assign (new_temp, NOP_EXPR, val);
-             vect_init_vector_1 (stmt_info, init_stmt, gsi);
-             val = new_temp;
+               /* ???  Condition vectorization expects us to do
+                  promotion of invariant/external defs.  */
+               val = gimple_convert (&stmts, TREE_TYPE (type), val);
+             for (gimple_stmt_iterator gsi2 = gsi_start (stmts);
+                  !gsi_end_p (gsi2); gsi_next (&gsi2))
+               vect_init_vector_1 (stmt_info, gsi_stmt (gsi2), gsi);
            }
        }
       val = build_vector_from_val (type, val);
Index: gcc/testsuite/gcc.dg/torture/pr90972.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr90972.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr90972.c      (working copy)
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mcpu=power8" { target powerpc*-*-* } } */
+
+long f;
+void a();
+void *g()
+{
+  char h[] = {}, j[] = {}, k[] = {}, l[] = {}, m[] = {}, n[] = {}, o[] = {},
+       q[] = {}, r[] = {};
+  static const char i[] = {6, 0};
+  const char *nops[] = {h, i, j, k, l, m, n, o, q, r};
+  long s = 2;
+  void *fill = a;
+  char *p = fill;
+  while (f) {
+      void *b = p;
+      const void *c = nops[1];
+      long d = s, e = __builtin_object_size(b, 0);
+      __builtin___memcpy_chk(b, c, d, e);
+      p += s;
+      f -= s;
+  }
+  return fill;
+}

Reply via email to