[gcc r12-6884] rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239]

Jakub Jelinek jakub@gcc.gnu.org
Wed Jan 26 21:08:11 GMT 2022


https://gcc.gnu.org/g:2bf8da684b712a16c67f3defc0dd97f175f8f4ad

commit r12-6884-g2bf8da684b712a16c67f3defc0dd97f175f8f4ad
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 26 22:07:29 2022 +0100

    rs6000: Fix up #include <immintrin.h> or <x86gprintrin.h> [PR104239]
    
    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.
    
    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.

Diff:
---
 gcc/config/rs6000/bmi2intrin.h                |  4 ++--
 gcc/config/rs6000/bmiintrin.h                 |  4 ++--
 gcc/testsuite/gcc.target/powerpc/pr104239-1.c | 10 ++++++++++
 gcc/testsuite/gcc.target/powerpc/pr104239-2.c | 10 ++++++++++
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rs6000/bmi2intrin.h b/gcc/config/rs6000/bmi2intrin.h
index 9bf36e99c0d..931a61d749f 100644
--- a/gcc/config/rs6000/bmi2intrin.h
+++ b/gcc/config/rs6000/bmi2intrin.h
@@ -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
diff --git a/gcc/config/rs6000/bmiintrin.h b/gcc/config/rs6000/bmiintrin.h
index 8845f70b543..76cbc4724aa 100644
--- a/gcc/config/rs6000/bmiintrin.h
+++ b/gcc/config/rs6000/bmiintrin.h
@@ -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
diff --git a/gcc/testsuite/gcc.target/powerpc/pr104239-1.c b/gcc/testsuite/gcc.target/powerpc/pr104239-1.c
new file mode 100644
index 00000000000..eacdedd5c38
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr104239-1.c
@@ -0,0 +1,10 @@
+/* PR target/104239 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power8 -DNO_WARN_X86_INTRINSICS" } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+
+#if __has_include(<immintrin.h>)
+#include <immintrin.h>
+#endif
+
+int i;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr104239-2.c b/gcc/testsuite/gcc.target/powerpc/pr104239-2.c
new file mode 100644
index 00000000000..1bf316f9701
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr104239-2.c
@@ -0,0 +1,10 @@
+/* PR target/104239 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power8 -DNO_WARN_X86_INTRINSICS" } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+
+#if __has_include(<x86gprintrin.h>)
+#include <x86gprintrin.h>
+#endif
+
+int i;


More information about the Gcc-cvs mailing list