public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239]
@ 2022-01-26 20:45 Jakub Jelinek
  2022-01-26 20:50 ` David Edelsohn
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Jelinek @ 2022-01-26 20:45 UTC (permalink / raw)
  To: Segher Boessenkool, David Edelsohn; +Cc: gcc-patches, Paul A. Clarke

Hi!

r12-4717-g7d37abedf58d66 added immintrin.h and x86gprintrin.h headers
to rs6000, these headers are on x86 standalone headers that various
programs include directly rather than including them through
<x86intrin.h>.
Unfortunately, for that change the bmiintrin.h and bmi2intrin.h
headers haven't been adjusted, so the effect is that if one includes them
(without including also x86intrin.h first) #error will trigger.
Furthermore, when including such headers conditionally as some real-world
packages do, this means a regression.

The following patch fixes it and matches what the x86 bmi{,2}intrin.h
headers do.

Bootstrapped/regtested on powerpc64le-linux, ok for trunk?

2022-01-26  Jakub Jelinek  <jakub@redhat.com>

	PR target/104239
	* config/rs6000/bmiintrin.h: Test _X86GPRINTRIN_H_INCLUDED instead of
	_X86INTRIN_H_INCLUDED and adjust #error wording.
	* config/rs6000/bmi2intrin.h: Likewise.

	* gcc.target/powerpc/pr104239-1.c: New test.
	* gcc.target/powerpc/pr104239-2.c: New test.

--- gcc/config/rs6000/bmiintrin.h.jj	2022-01-11 23:11:21.936296534 +0100
+++ gcc/config/rs6000/bmiintrin.h	2022-01-26 13:35:08.705945170 +0100
@@ -29,8 +29,8 @@
    standard C or GNU C extensions, which are more portable and better
    optimized across multiple targets.  */
 
-#if !defined _X86INTRIN_H_INCLUDED
-# error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
+#if !defined _X86GPRINTRIN_H_INCLUDED
+# error "Never use <bmiintrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _BMIINTRIN_H_INCLUDED
--- gcc/config/rs6000/bmi2intrin.h.jj	2022-01-11 23:11:21.936296534 +0100
+++ gcc/config/rs6000/bmi2intrin.h	2022-01-26 13:34:53.373162122 +0100
@@ -29,8 +29,8 @@
    standard C or GNU C extensions, which are more portable and better
    optimized across multiple targets.  */
 
-#if !defined _X86INTRIN_H_INCLUDED
-# error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
+#if !defined _X86GPRINTRIN_H_INCLUDED
+# error "Never use <bmi2intrin.h> directly; include <x86gprintrin.h> instead."
 #endif
 
 #ifndef _BMI2INTRIN_H_INCLUDED
--- gcc/testsuite/gcc.target/powerpc/pr104239-1.c.jj	2022-01-26 13:42:34.103643030 +0100
+++ gcc/testsuite/gcc.target/powerpc/pr104239-1.c	2022-01-26 13:42:23.101798701 +0100
@@ -0,0 +1,9 @@
+/* PR target/104239 */
+/* { dg-do compile } */
+/* { dg-options "-DNO_WARN_X86_INTRINSICS" } */
+
+#if __has_include(<immintrin.h>)
+#include <immintrin.h>
+#endif
+
+int i;
--- gcc/testsuite/gcc.target/powerpc/pr104239-2.c.jj	2022-01-26 13:42:42.279527345 +0100
+++ gcc/testsuite/gcc.target/powerpc/pr104239-2.c	2022-01-26 13:42:23.101798701 +0100
@@ -0,0 +1,9 @@
+/* PR target/104239 */
+/* { dg-do compile } */
+/* { dg-options "-DNO_WARN_X86_INTRINSICS" } */
+
+#if __has_include(<x86gprintrin.h>)
+#include <x86gprintrin.h>
+#endif
+
+int i;

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239]
  2022-01-26 20:45 [PATCH] rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239] Jakub Jelinek
@ 2022-01-26 20:50 ` David Edelsohn
  2022-01-27 20:55   ` Paul A. Clarke
  0 siblings, 1 reply; 4+ messages in thread
From: David Edelsohn @ 2022-01-26 20:50 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Segher Boessenkool, GCC Patches, Paul A. Clarke

On Wed, Jan 26, 2022 at 3:45 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> r12-4717-g7d37abedf58d66 added immintrin.h and x86gprintrin.h headers
> to rs6000, these headers are on x86 standalone headers that various
> programs include directly rather than including them through
> <x86intrin.h>.
> Unfortunately, for that change the bmiintrin.h and bmi2intrin.h
> headers haven't been adjusted, so the effect is that if one includes them
> (without including also x86intrin.h first) #error will trigger.
> Furthermore, when including such headers conditionally as some real-world
> packages do, this means a regression.
>
> The following patch fixes it and matches what the x86 bmi{,2}intrin.h
> headers do.
>
> Bootstrapped/regtested on powerpc64le-linux, ok for trunk?

Okay.

Thanks for catching this.

- David

>
> 2022-01-26  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/104239
>         * config/rs6000/bmiintrin.h: Test _X86GPRINTRIN_H_INCLUDED instead of
>         _X86INTRIN_H_INCLUDED and adjust #error wording.
>         * config/rs6000/bmi2intrin.h: Likewise.
>
>         * gcc.target/powerpc/pr104239-1.c: New test.
>         * gcc.target/powerpc/pr104239-2.c: New test.
>
> --- gcc/config/rs6000/bmiintrin.h.jj    2022-01-11 23:11:21.936296534 +0100
> +++ gcc/config/rs6000/bmiintrin.h       2022-01-26 13:35:08.705945170 +0100
> @@ -29,8 +29,8 @@
>     standard C or GNU C extensions, which are more portable and better
>     optimized across multiple targets.  */
>
> -#if !defined _X86INTRIN_H_INCLUDED
> -# error "Never use <bmiintrin.h> directly; include <x86intrin.h> instead."
> +#if !defined _X86GPRINTRIN_H_INCLUDED
> +# error "Never use <bmiintrin.h> directly; include <x86gprintrin.h> instead."
>  #endif
>
>  #ifndef _BMIINTRIN_H_INCLUDED
> --- gcc/config/rs6000/bmi2intrin.h.jj   2022-01-11 23:11:21.936296534 +0100
> +++ gcc/config/rs6000/bmi2intrin.h      2022-01-26 13:34:53.373162122 +0100
> @@ -29,8 +29,8 @@
>     standard C or GNU C extensions, which are more portable and better
>     optimized across multiple targets.  */
>
> -#if !defined _X86INTRIN_H_INCLUDED
> -# error "Never use <bmi2intrin.h> directly; include <x86intrin.h> instead."
> +#if !defined _X86GPRINTRIN_H_INCLUDED
> +# error "Never use <bmi2intrin.h> directly; include <x86gprintrin.h> instead."
>  #endif
>
>  #ifndef _BMI2INTRIN_H_INCLUDED
> --- gcc/testsuite/gcc.target/powerpc/pr104239-1.c.jj    2022-01-26 13:42:34.103643030 +0100
> +++ gcc/testsuite/gcc.target/powerpc/pr104239-1.c       2022-01-26 13:42:23.101798701 +0100
> @@ -0,0 +1,9 @@
> +/* PR target/104239 */
> +/* { dg-do compile } */
> +/* { dg-options "-DNO_WARN_X86_INTRINSICS" } */
> +
> +#if __has_include(<immintrin.h>)
> +#include <immintrin.h>
> +#endif
> +
> +int i;
> --- gcc/testsuite/gcc.target/powerpc/pr104239-2.c.jj    2022-01-26 13:42:42.279527345 +0100
> +++ gcc/testsuite/gcc.target/powerpc/pr104239-2.c       2022-01-26 13:42:23.101798701 +0100
> @@ -0,0 +1,9 @@
> +/* PR target/104239 */
> +/* { dg-do compile } */
> +/* { dg-options "-DNO_WARN_X86_INTRINSICS" } */
> +
> +#if __has_include(<x86gprintrin.h>)
> +#include <x86gprintrin.h>
> +#endif
> +
> +int i;
>
>         Jakub
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239]
  2022-01-26 20:50 ` David Edelsohn
@ 2022-01-27 20:55   ` Paul A. Clarke
  2022-01-27 23:47     ` Segher Boessenkool
  0 siblings, 1 reply; 4+ messages in thread
From: Paul A. Clarke @ 2022-01-27 20:55 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Jakub Jelinek, GCC Patches, Segher Boessenkool

On Wed, Jan 26, 2022 at 03:50:35PM -0500, David Edelsohn via Gcc-patches wrote:
> On Wed, Jan 26, 2022 at 3:45 PM Jakub Jelinek <jakub@redhat.com> wrote:
> > r12-4717-g7d37abedf58d66 added immintrin.h and x86gprintrin.h headers
> > to rs6000, these headers are on x86 standalone headers that various
> > programs include directly rather than including them through
> > <x86intrin.h>.
> > Unfortunately, for that change the bmiintrin.h and bmi2intrin.h
> > headers haven't been adjusted, so the effect is that if one includes them
> > (without including also x86intrin.h first) #error will trigger.
> > Furthermore, when including such headers conditionally as some real-world
> > packages do, this means a regression.
> >
> > The following patch fixes it and matches what the x86 bmi{,2}intrin.h
> > headers do.
> 
> Okay.
> 
> Thanks for catching this.

Indeed, thanks. And thanks for reviewing, David.

Should we add similar compile-only tests for all of the standalone include
files?

PC

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239]
  2022-01-27 20:55   ` Paul A. Clarke
@ 2022-01-27 23:47     ` Segher Boessenkool
  0 siblings, 0 replies; 4+ messages in thread
From: Segher Boessenkool @ 2022-01-27 23:47 UTC (permalink / raw)
  To: Paul A. Clarke; +Cc: David Edelsohn, Jakub Jelinek, GCC Patches

On Thu, Jan 27, 2022 at 02:55:08PM -0600, Paul A. Clarke wrote:
> Should we add similar compile-only tests for all of the standalone include
> files?

The only reason it wasn't detected earlier is that no one actually uses
this (and tests the development compiler).  That is a much bigger
problem, and nothing that a few scattershot tests will help fix :-(


Segher

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-27 23:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 20:45 [PATCH] rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239] Jakub Jelinek
2022-01-26 20:50 ` David Edelsohn
2022-01-27 20:55   ` Paul A. Clarke
2022-01-27 23:47     ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).