re PR tree-optimization/87785 (ICE in dr_misalignment, at tree-vectorizer.h:1245...
authorRichard Biener <rguenther@suse.de>
Mon, 29 Oct 2018 15:43:08 +0000 (15:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 29 Oct 2018 15:43:08 +0000 (15:43 +0000)
2018-10-29  Richard Biener  <rguenther@suse.de>

PR tree-optimization/87785
* tree-vect-slp.c (vect_gather_slp_loads): Only gather
internal defs.

* gcc.dg/torture/20181029-1.c: New testcase.
* gcc.dg/torture/20181029-2.c: Likewise.

From-SVN: r265596

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/20181029-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/20181029-2.c [new file with mode: 0644]
gcc/tree-vect-slp.c

index 735bb897a9929f6f217844939ad0c8487761bc3f..fec9ddf3e4987497c0b3014311eb194dd5f5b169 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87785
+       * tree-vect-slp.c (vect_gather_slp_loads): Only gather
+       internal defs.
+
 2018-10-29  Olivier Hainque  <hainque@adacore.com>
 
        * VXWORKS_NET_LIBS_RTP: New macro, network part of VXWORKS_LIBS_RTP.
index fa6d53717ab154823f3abd563c2c2547258bf58a..6cc3e1bb86a355ed51fcdc696db7ebce808cb4c0 100644 (file)
@@ -1,3 +1,9 @@
+2018-10-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87785
+       * gcc.dg/torture/20181029-1.c: New testcase.
+       * gcc.dg/torture/20181029-2.c: Likewise.
+
 2018-10-29  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/87790
diff --git a/gcc/testsuite/gcc.dg/torture/20181029-1.c b/gcc/testsuite/gcc.dg/torture/20181029-1.c
new file mode 100644 (file)
index 0000000..6576719
--- /dev/null
@@ -0,0 +1,81 @@
+/* { dg-do compile } */
+
+typedef __SIZE_TYPE__ size_t;
+typedef unsigned long UV;
+typedef size_t STRLEN;
+typedef struct sv SV;
+typedef struct magic MAGIC;
+typedef struct xpv XPV;
+typedef unsigned char U8;
+typedef int I32;
+typedef unsigned int U32;
+struct sv {
+    void* sv_any;
+    U32 sv_flags;
+};
+struct xpv {
+    char * xpv_pv;
+    STRLEN xpv_cur;
+};
+struct magic {
+    char* mg_ptr;
+};
+extern const unsigned char PL_utf8skip[];
+char *Perl_sv_2pv_flags (STRLEN *);
+void Perl_utf8n_to_uvuni (U8 *);
+void Perl_sv_magic (SV *);
+void Perl_sv_pos_b2u( register SV* sv, I32* offsetp, MAGIC *mg)
+{
+  U8* s;
+  STRLEN len;
+  s = (U8*)(((sv)->sv_flags & (0x00040000)) == 0x00040000
+           ? ((len = ((XPV*) (sv)->sv_any)->xpv_cur), ((XPV*) (sv)->sv_any)->xpv_pv)
+           : Perl_sv_2pv_flags(&len));
+  if ((I32)len < *offsetp)
+    ;
+  else
+    {
+      STRLEN *cache = ((void *)0);
+      if (((sv)->sv_flags & (0x00002000|0x00004000|0x00008000))
+         && !((sv)->sv_flags & 0x00800000))
+       {
+         if (mg && mg->mg_ptr)
+           {
+             cache = (STRLEN *) mg->mg_ptr;
+             STRLEN forw = *offsetp;
+             STRLEN backw = cache[1] - *offsetp;
+             if (!(forw < 2 * backw))
+               {
+                 U8 *p = s + cache[1];
+                 STRLEN ubackw = 0;
+                 cache[1] -= backw;
+                 while (backw--)
+                   {
+                     p--;
+                     while ((((U8)*p) >= 0x80 && (((U8)*p) <= 0xbf)))
+                       {
+                         p--;
+                         backw--;
+                       }
+                     ubackw++;
+                   }
+                 cache[0] -= ubackw;
+                 *offsetp = cache[0];
+                 cache[2] = 0;
+                 cache[3] = 0;
+                 return;
+               }
+           }
+         if (!(((UV)(*s)) < 0x80))
+           Perl_utf8n_to_uvuni(s);
+       }
+      if (!((sv)->sv_flags & 0x00800000))
+       {
+         if (!mg)
+           Perl_sv_magic(sv);
+         cache[0] = len;
+         cache[1] = *offsetp;
+       }
+      *offsetp = len;
+    }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/20181029-2.c b/gcc/testsuite/gcc.dg/torture/20181029-2.c
new file mode 100644 (file)
index 0000000..65a3656
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+int a, b;
+unsigned long c;
+unsigned long *d;
+void e();
+void f()
+{
+  if (c)
+    {
+      if (a)
+       {
+         e();
+         d[0] = c;
+         d[1] = b;
+       }
+      b = c;
+    }
+}
index a1db0dfde86e44ee5ce6d1b55914e733f4457fe6..6ec7358c2dc2c7ddaa9846f7603b520a095d781f 100644 (file)
@@ -1645,7 +1645,8 @@ vect_gather_slp_loads (slp_instance inst, slp_tree node,
   if (SLP_TREE_CHILDREN (node).length () == 0)
     {
       stmt_vec_info stmt_info = SLP_TREE_SCALAR_STMTS (node)[0];
-      if (STMT_VINFO_GROUPED_ACCESS (stmt_info)
+      if (SLP_TREE_DEF_TYPE (node) == vect_internal_def
+         && STMT_VINFO_GROUPED_ACCESS (stmt_info)
          && DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info)))
        SLP_INSTANCE_LOADS (inst).safe_push (node);
     }