[committed] openmp: One omp_resolve_declare_variant followup [PR95315]

Message ID 20200529085133.GI8462@tucnak
State New
Headers show
Series
  • [committed] openmp: One omp_resolve_declare_variant followup [PR95315]
Related show

Commit Message

Kewen.Lin via Gcc-patches May 29, 2020, 8:51 a.m.
Hi!

As noticed by Arseny, I got the condition when to call the add removal hook
wrong wrong.  Fixed thusly, bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk.

2020-05-28  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/95315
	* omp-general.c (omp_resolve_declare_variant): Fix up addition of
	declare variant cgraph node removal callback.

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



	Jakub

Patch

--- gcc/omp-general.c.jj	2020-05-27 10:25:35.855578064 +0200
+++ gcc/omp-general.c	2020-05-28 19:39:38.575186925 +0200
@@ -1851,7 +1851,7 @@  omp_resolve_declare_variant (tree base)
 	}
 
       static struct cgraph_node_hook_list *node_removal_hook_holder;
-      if (node_removal_hook_holder)
+      if (!node_removal_hook_holder)
 	node_removal_hook_holder
 	  = symtab->add_cgraph_removal_hook (omp_declare_variant_remove_hook,
 					     NULL);
--- gcc/testsuite/gcc.dg/gomp/pr95315-2.c.jj	2020-05-28 19:41:26.765630849 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr95315-2.c	2020-05-28 19:32:34.511286132 +0200
@@ -0,0 +1,46 @@ 
+/* PR middle-end/95315 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp --param ggc-min-heapsize=0" } */
+
+typedef float __v4sf __attribute__((vector_size (16)));
+typedef int __v4si __attribute__((vector_size (16)));
+typedef float __v8sf __attribute__((vector_size (32)));
+typedef int __v8si __attribute__((vector_size (32)));
+__v4si f1 (__v4sf, __v4sf, float *);
+__v8si f2 (__v8sf, __v8sf, float *);
+__v4si f3 (__v4si, int, __v4si);
+
+#pragma omp declare variant (f1) match (construct={parallel,for,simd(simdlen(4),notinbranch,uniform(z),aligned(z:4 * sizeof (*z)))})
+#pragma omp declare variant (f2) match (construct={for,simd(uniform(z),simdlen(8),notinbranch)})
+int f4 (float x, float y, float *z);
+
+#pragma omp declare variant (f3) match (construct={simd(simdlen(4),inbranch,linear(y:1))})
+int f5 (int x, int y);
+
+static inline __attribute__((always_inline)) int
+ret_false (void)
+{
+  return 0;
+}
+
+void
+test (int *x, float *y, float *z, float *w)
+{
+  #pragma omp parallel
+  #pragma omp for simd aligned (w:4 * sizeof (float))
+  for (int i = 0; i < 1024; i++)
+    if (ret_false ())
+      x[i] = f4 (y[i], z[i], w);
+  #pragma omp parallel for simd aligned (w:4 * sizeof (float)) simdlen(4)
+  for (int i = 1024; i < 2048; i++)
+    if (ret_false ())
+      x[i] = f4 (y[i], z[i], w);
+  #pragma omp simd aligned (w:4 * sizeof (float))
+  for (int i = 2048; i < 4096; i++)
+    if (ret_false ())
+      x[i] = f4 (y[i], z[i], w);
+  #pragma omp simd
+  for (int i = 4096; i < 8192; i++)
+    if (x[i] > 10 && ret_false ())
+      x[i] = f5 (x[i], i);
+}