re PR middle-end/89246 (LTO produces references to cloned symbols which the compiler...
authorJakub Jelinek <jakub@redhat.com>
Sat, 9 Feb 2019 08:55:39 +0000 (09:55 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 9 Feb 2019 08:55:39 +0000 (09:55 +0100)
PR middle-end/89246
* config/i386/i386.c (ix86_simd_clone_compute_vecsize_and_simdlen):
If !node->definition and TYPE_ARG_TYPES is non-NULL, use
TYPE_ARG_TYPES instead of DECL_ARGUMENTS.

* gcc.dg/gomp/pr89246-1.c: New test.
* gcc.dg/gomp/pr89246-2.c: New test.

From-SVN: r268718

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gomp/pr89246-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr89246-2.c [new file with mode: 0644]

index 0079a6948e84299c666f8d4a3db342a947bdeed8..c6a97e1b4c0de0ec5f4b34c237aecefc22a56bb5 100644 (file)
@@ -1,3 +1,10 @@
+2019-02-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89246
+       * config/i386/i386.c (ix86_simd_clone_compute_vecsize_and_simdlen):
+       If !node->definition and TYPE_ARG_TYPES is non-NULL, use
+       TYPE_ARG_TYPES instead of DECL_ARGUMENTS.
+
 2019-02-09  Alan Modra  <amodra@gmail.com>
 
        PR target/88343
index 579a3ee3037af9668da9bf05e0ed7454fe84ca64..12bc7926f864d6803fee9c8c03ea6f74dc8e4c15 100644 (file)
@@ -50447,28 +50447,34 @@ ix86_simd_clone_compute_vecsize_and_simdlen (struct cgraph_node *node,
 
   tree t;
   int i;
+  tree type_arg_types = TYPE_ARG_TYPES (TREE_TYPE (node->decl));
+  bool decl_arg_p = (node->definition || type_arg_types == NULL_TREE);
 
-  for (t = DECL_ARGUMENTS (node->decl), i = 0; t; t = DECL_CHAIN (t), i++)
-    switch (TYPE_MODE (TREE_TYPE (t)))
-      {
-      case E_QImode:
-      case E_HImode:
-      case E_SImode:
-      case E_DImode:
-      case E_SFmode:
-      case E_DFmode:
-      /* case E_SCmode: */
-      /* case E_DCmode: */
-       if (!AGGREGATE_TYPE_P (TREE_TYPE (t)))
-         break;
-       /* FALLTHRU */
-      default:
-       if (clonei->args[i].arg_type == SIMD_CLONE_ARG_TYPE_UNIFORM)
-         break;
-       warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
-                   "unsupported argument type %qT for simd", TREE_TYPE (t));
-       return 0;
-      }
+  for (t = (decl_arg_p ? DECL_ARGUMENTS (node->decl) : type_arg_types), i = 0;
+       t && t != void_list_node; t = TREE_CHAIN (t), i++)
+    {
+      tree arg_type = decl_arg_p ? TREE_TYPE (t) : TREE_VALUE (t);
+      switch (TYPE_MODE (arg_type))
+       {
+       case E_QImode:
+       case E_HImode:
+       case E_SImode:
+       case E_DImode:
+       case E_SFmode:
+       case E_DFmode:
+       /* case E_SCmode: */
+       /* case E_DCmode: */
+         if (!AGGREGATE_TYPE_P (arg_type))
+           break;
+         /* FALLTHRU */
+       default:
+         if (clonei->args[i].arg_type == SIMD_CLONE_ARG_TYPE_UNIFORM)
+           break;
+         warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
+                     "unsupported argument type %qT for simd", arg_type);
+         return 0;
+       }
+    }
 
   if (!TREE_PUBLIC (node->decl))
     {
index 814a861d78205bc0937ea4a58e4f0335e420b727..dd887d35378deee9aab495d095b09551ccd5385d 100644 (file)
@@ -1,3 +1,9 @@
+2019-02-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/89246
+       * gcc.dg/gomp/pr89246-1.c: New test.
+       * gcc.dg/gomp/pr89246-2.c: New test.
+
 2019-02-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/88739
diff --git a/gcc/testsuite/gcc.dg/gomp/pr89246-1.c b/gcc/testsuite/gcc.dg/gomp/pr89246-1.c
new file mode 100644 (file)
index 0000000..dfe629c
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR middle-end/89246 */
+/* { dg-do link { target { int128 && vect_simd_clones } } } */
+/* { dg-options "-O2 -fopenmp-simd -w" } */
+/* { dg-additional-sources "pr89246-2.c" } */
+
+#pragma omp declare simd
+int foo (__int128 x)
+{
+  return x;
+}
+
+#pragma omp declare simd
+extern int bar (int x);
+
+int
+main ()
+{
+  return foo (0) + bar (0);
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/pr89246-2.c b/gcc/testsuite/gcc.dg/gomp/pr89246-2.c
new file mode 100644 (file)
index 0000000..ccdcaf5
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/89246 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O0 -fno-openmp -fno-openmp-simd" } */
+
+#pragma omp declare simd
+extern int foo (__int128 x);
+
+#pragma omp declare simd
+int
+bar (int x)
+{
+  return x + foo (0);
+}