re PR tree-optimization/80705 (Incorrect code generated for profile counter updates...
authorRichard Biener <rguenther@suse.de>
Thu, 11 May 2017 14:08:07 +0000 (14:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 11 May 2017 14:08:07 +0000 (14:08 +0000)
2017-05-11  Richard Biener  <rguenther@suse.de>

PR tree-optimization/80705
* tree-vect-data-refs.c (vect_analyze_data_refs): DECL_NONALIASED
bases are not vectorizable.

* gcc.dg/vect/bb-slp-pr80705.c: New testcase.

From-SVN: r247906

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/bb-slp-pr80705.c [new file with mode: 0644]
gcc/tree-vect-data-refs.c

index 3430b1e3c7cf25d0c1fda7e5fdfc18501962c4eb..a317c211ebe77ac5477820799c143e91902ba8c4 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-11  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/80705
+       * tree-vect-data-refs.c (vect_analyze_data_refs): DECL_NONALIASED
+       bases are not vectorizable.
+
 2017-05-11  Bin Cheng  <bin.cheng@arm.com>
 
        * tree-ssa-loop-ivopts.c (determine_set_costs): Skip non-interger
index 832eba38ec04f3135b1f217bd6ccafe7635476f3..1af2958dfee2d23568b858ebed12e979ee01fa3d 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-11  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/80705
+       * gcc.dg/vect/bb-slp-pr80705.c: New testcase.
+
 2017-05-11  Nathan Sidwell  <nathan@acm.org>
 
        * lib/scanlang.exp: New.
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr80705.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr80705.c
new file mode 100644 (file)
index 0000000..189e3d1
--- /dev/null
@@ -0,0 +1,44 @@
+/* { dg-do compile } */
+/* { dg-require-profiling "-fprofile-generate" } */
+/* { dg-additional-options "-fprofile-generate" } */
+
+extern int isspace (int);
+
+int foo(const char *txt, char *buf)
+{
+  const char *s;
+  char *d;
+  int ws = 1;
+  for (s=txt, d=buf; *s; )
+    {
+      if (*s=='/' && *(s+1)=='/') {
+
+         s += 2;
+         while (*s && *s!='\r' && *s!='\n')
+           s++;
+      }
+      else if (*s=='"') {
+
+         s++;
+         while (*s && *s!='\r' && *s!='\n' && *s!='"')
+           if (*s++=='\\')
+             s++;
+         if (*s=='"')
+           s++;
+      }
+      else {
+         if (*s && !isspace(*s))
+           ws = 0;
+
+
+         *d++ = *s++;
+
+      }
+    }
+  *d = '\0';
+
+  return ws;
+}
+
+/* { dg-final { scan-tree-dump "base object not addressable" "slp1" } } */
+/* { dg-final { scan-tree-dump-not "MEM\[^\r\n\]*__gcov\[^\r\n\]* = vect_cst" "slp1" } } */
index c97426882e82ffa11abdb900fe2c26f45373a3bf..67cc969757df2d0a23f6b716704ff8370086763b 100644 (file)
@@ -3957,6 +3957,27 @@ again:
          datarefs[i] = dr;
        }
 
+      if (TREE_CODE (DR_BASE_ADDRESS (dr)) == ADDR_EXPR
+         && VAR_P (TREE_OPERAND (DR_BASE_ADDRESS (dr), 0))
+         && DECL_NONALIASED (TREE_OPERAND (DR_BASE_ADDRESS (dr), 0)))
+       {
+          if (dump_enabled_p ())
+            {
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "not vectorized: base object not addressable "
+                              "for stmt: ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+            }
+          if (is_a <bb_vec_info> (vinfo))
+           {
+             /* In BB vectorization the ref can still participate
+                in dependence analysis, we just can't vectorize it.  */
+             STMT_VINFO_VECTORIZABLE (stmt_info) = false;
+             continue;
+           }
+         return false;
+       }
+
       /* Set vectype for STMT.  */
       scalar_type = TREE_TYPE (DR_REF (dr));
       STMT_VINFO_VECTYPE (stmt_info)