re PR middle-end/79649 (Memset pattern in named address space crashes compiler or...
authorJakub Jelinek <jakub@redhat.com>
Tue, 21 Feb 2017 16:29:37 +0000 (17:29 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 21 Feb 2017 16:29:37 +0000 (17:29 +0100)
PR tree-optimization/79649
* tree-loop-distribution.c (classify_partition): Give up on
non-generic address space loads/stores.

* gcc.target/i386/pr79649.c: New test.

From-SVN: r245631

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr79649.c [new file with mode: 0644]
gcc/tree-loop-distribution.c

index 05bdf01c8bfb6995bd029548146fb6d5ea730411..0697aeccb9eff88a86886df539cad3fdd6457809 100644 (file)
@@ -1,3 +1,9 @@
+2017-02-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/79649
+       * tree-loop-distribution.c (classify_partition): Give up on
+       non-generic address space loads/stores.
+
 2017-02-21  Aldy Hernandez  <aldyh@redhat.com>
 
        * doc/loop.texi (Loop manipulation): Remove nonexistent
index b9c70a7b77b09b2ea537233398a1fd580415d294..e35dd7c0cda0194804ccfcd8565653098dcb3311 100644 (file)
@@ -1,5 +1,8 @@
 2017-02-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/79649
+       * gcc.target/i386/pr79649.c: New test.
+
        PR target/79494
        * gcc.dg/pr79494.c: New test.
 
diff --git a/gcc/testsuite/gcc.target/i386/pr79649.c b/gcc/testsuite/gcc.target/i386/pr79649.c
new file mode 100644 (file)
index 0000000..e3d0110
--- /dev/null
@@ -0,0 +1,53 @@
+/* PR tree-optimization/79649 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-not "__builtin_memset" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__builtin_memcpy" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__builtin_memmove" "optimized" } } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void
+f1 (unsigned char __seg_gs *s, size_t n)
+{
+  for (size_t i = 0; i < n; ++i)
+    s[i] = 0;
+}
+
+void
+f2 (unsigned char __seg_gs *__restrict d, unsigned char __seg_gs *__restrict s, size_t n)
+{
+  for (size_t i = 0; i < n; ++i)
+    d[i] = s[i];
+}
+
+void
+f3 (unsigned char __seg_gs *__restrict d, unsigned char *__restrict s, size_t n)
+{
+  for (size_t i = 0; i < n; ++i)
+    d[i] = s[i];
+}
+
+void
+f4 (unsigned char *__restrict d, unsigned char __seg_gs *__restrict s, size_t n)
+{
+  for (size_t i = 0; i < n; ++i)
+    d[i] = s[i];
+}
+
+void
+f5 (unsigned char __seg_gs *__restrict d, unsigned char __seg_fs *__restrict s, size_t n)
+{
+  for (size_t i = 0; i < n; ++i)
+    d[i] = s[i];
+}
+
+struct A { int a; char b[1024]; };
+extern struct A __seg_gs a;
+
+void
+f6 (size_t n)
+{
+  for (size_t i = 0; i < n; ++i)
+    a.b[i] = 0;
+}
index 0fec1d6121ce0c510ad959d61f1a1744527d7c6f..4b94d0f9f8a52b5229b79c9414e8275f3064664f 100644 (file)
@@ -1072,6 +1072,13 @@ classify_partition (loop_p loop, struct graph *rdg, partition *partition)
       /* But exactly one store and/or load.  */
       for (j = 0; RDG_DATAREFS (rdg, i).iterate (j, &dr); ++j)
        {
+         tree type = TREE_TYPE (DR_REF (dr));
+
+         /* The memset, memcpy and memmove library calls are only
+            able to deal with generic address space.  */
+         if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (type)))
+           return;
+
          if (DR_IS_READ (dr))
            {
              if (single_load != NULL)