diff mbox

Fix ICE for SIMD clones usage in LTO

Message ID 20151005161346.GA63757@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Oct. 5, 2015, 4:13 p.m. UTC
Hi,

When SIMD clone is created original function may be defined in another partition.  In this case SIMD clone also has to have in_other_partition flag.  Now it doesn't and we get an ICE.  This patch fixes it.  Bootstrapped and regtested for x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
gcc/

2015-10-05  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* omp-low.c (simd_clone_create): Set in_other_partition
	for created clones.

gcc/testsuite/

2015-10-05  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* gcc.dg/lto/simd-function_0.c: New test.

Comments

Ilya Enkovich Oct. 21, 2015, 12:57 p.m. UTC | #1
Ping

2015-10-05 19:13 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> Hi,
>
> When SIMD clone is created original function may be defined in another partition.  In this case SIMD clone also has to have in_other_partition flag.  Now it doesn't and we get an ICE.  This patch fixes it.  Bootstrapped and regtested for x86_64-unknown-linux-gnu.  OK for trunk?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-10-05  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * omp-low.c (simd_clone_create): Set in_other_partition
>         for created clones.
>
> gcc/testsuite/
>
> 2015-10-05  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * gcc.dg/lto/simd-function_0.c: New test.
>
>
> diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> index cdcf9d6..8d25784 100644
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -12948,6 +12948,8 @@ simd_clone_create (struct cgraph_node *old_node)
>        DECL_STATIC_CONSTRUCTOR (new_decl) = 0;
>        DECL_STATIC_DESTRUCTOR (new_decl) = 0;
>        new_node = old_node->create_version_clone (new_decl, vNULL, NULL);
> +      if (old_node->in_other_partition)
> +       new_node->in_other_partition = 1;
>        symtab->call_cgraph_insertion_hooks (new_node);
>      }
>    if (new_node == NULL)
> diff --git a/gcc/testsuite/gcc.dg/lto/simd-function_0.c b/gcc/testsuite/gcc.dg/lto/simd-function_0.c
> new file mode 100755
> index 0000000..cda31aa
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/lto/simd-function_0.c
> @@ -0,0 +1,34 @@
> +/* { dg-lto-do link } */
> +/* { dg-require-effective-target avx2 } */
> +/* { dg-lto-options { { -fopenmp-simd -O3 -ffast-math -mavx2 -flto -flto-partition=max } } } */
> +
> +#define SIZE 4096
> +float x[SIZE];
> +
> +
> +#pragma omp declare simd
> +float
> +__attribute__ ((noinline))
> +my_mul (float x, float y) {
> +  return x * y;
> +}
> +
> +__attribute__ ((noinline))
> +int foo ()
> +{
> +  int i = 0;
> +#pragma omp simd safelen (16)
> +  for (i = 0; i < SIZE; i++)
> +    x[i] = my_mul ((float)i, 9932.3323);
> +  return (int)x[0];
> +}
> +
> +int main ()
> +{
> +  int i = 0;
> +  for (i = 0; i < SIZE; i++)
> +    x[i] = my_mul ((float) i, 9932.3323);
> +  foo ();
> +  return (int)x[0];
> +}
> +
Jakub Jelinek Oct. 21, 2015, 1:02 p.m. UTC | #2
On Wed, Oct 21, 2015 at 03:57:14PM +0300, Ilya Enkovich wrote:
> Ping

This is ok for trunk.

> > 2015-10-05  Ilya Enkovich  <enkovich.gnu@gmail.com>
> >
> >         * omp-low.c (simd_clone_create): Set in_other_partition
> >         for created clones.
> >
> > gcc/testsuite/
> >
> > 2015-10-05  Ilya Enkovich  <enkovich.gnu@gmail.com>
> >
> >         * gcc.dg/lto/simd-function_0.c: New test.
> >
> >
> > diff --git a/gcc/omp-low.c b/gcc/omp-low.c
> > index cdcf9d6..8d25784 100644
> > --- a/gcc/omp-low.c
> > +++ b/gcc/omp-low.c
> > @@ -12948,6 +12948,8 @@ simd_clone_create (struct cgraph_node *old_node)
> >        DECL_STATIC_CONSTRUCTOR (new_decl) = 0;
> >        DECL_STATIC_DESTRUCTOR (new_decl) = 0;
> >        new_node = old_node->create_version_clone (new_decl, vNULL, NULL);
> > +      if (old_node->in_other_partition)
> > +       new_node->in_other_partition = 1;
> >        symtab->call_cgraph_insertion_hooks (new_node);
> >      }
> >    if (new_node == NULL)
> > diff --git a/gcc/testsuite/gcc.dg/lto/simd-function_0.c b/gcc/testsuite/gcc.dg/lto/simd-function_0.c
> > new file mode 100755
> > index 0000000..cda31aa
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.dg/lto/simd-function_0.c
> > @@ -0,0 +1,34 @@
> > +/* { dg-lto-do link } */
> > +/* { dg-require-effective-target avx2 } */
> > +/* { dg-lto-options { { -fopenmp-simd -O3 -ffast-math -mavx2 -flto -flto-partition=max } } } */
> > +
> > +#define SIZE 4096
> > +float x[SIZE];
> > +
> > +
> > +#pragma omp declare simd
> > +float
> > +__attribute__ ((noinline))
> > +my_mul (float x, float y) {
> > +  return x * y;
> > +}
> > +
> > +__attribute__ ((noinline))
> > +int foo ()
> > +{
> > +  int i = 0;
> > +#pragma omp simd safelen (16)
> > +  for (i = 0; i < SIZE; i++)
> > +    x[i] = my_mul ((float)i, 9932.3323);
> > +  return (int)x[0];
> > +}
> > +
> > +int main ()
> > +{
> > +  int i = 0;
> > +  for (i = 0; i < SIZE; i++)
> > +    x[i] = my_mul ((float) i, 9932.3323);
> > +  foo ();
> > +  return (int)x[0];
> > +}
> > +

	Jakub
diff mbox

Patch

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index cdcf9d6..8d25784 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -12948,6 +12948,8 @@  simd_clone_create (struct cgraph_node *old_node)
       DECL_STATIC_CONSTRUCTOR (new_decl) = 0;
       DECL_STATIC_DESTRUCTOR (new_decl) = 0;
       new_node = old_node->create_version_clone (new_decl, vNULL, NULL);
+      if (old_node->in_other_partition)
+	new_node->in_other_partition = 1;
       symtab->call_cgraph_insertion_hooks (new_node);
     }
   if (new_node == NULL)
diff --git a/gcc/testsuite/gcc.dg/lto/simd-function_0.c b/gcc/testsuite/gcc.dg/lto/simd-function_0.c
new file mode 100755
index 0000000..cda31aa
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/simd-function_0.c
@@ -0,0 +1,34 @@ 
+/* { dg-lto-do link } */
+/* { dg-require-effective-target avx2 } */
+/* { dg-lto-options { { -fopenmp-simd -O3 -ffast-math -mavx2 -flto -flto-partition=max } } } */
+
+#define SIZE 4096
+float x[SIZE];
+
+
+#pragma omp declare simd
+float
+__attribute__ ((noinline))
+my_mul (float x, float y) {
+  return x * y;
+}
+
+__attribute__ ((noinline))
+int foo ()
+{
+  int i = 0;
+#pragma omp simd safelen (16)
+  for (i = 0; i < SIZE; i++)
+    x[i] = my_mul ((float)i, 9932.3323);
+  return (int)x[0];
+}
+
+int main ()
+{
+  int i = 0;
+  for (i = 0; i < SIZE; i++)
+    x[i] = my_mul ((float) i, 9932.3323);
+  foo ();
+  return (int)x[0];
+}
+