From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by sourceware.org (Postfix) with ESMTPS id 8F344385B804 for ; Fri, 6 May 2022 09:17:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F344385B804 Received: by mail-qv1-xf30.google.com with SMTP id p3so3516453qvi.7 for ; Fri, 06 May 2022 02:17:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=bWGj1AAWyyeIArLDqj7/SFOLCA3Fzy0BrtGChcZhRI8=; b=YJnUZsFP/JYxt6PmHdOVVY01K4vHkPx3No67XnpkWtBA+v5VzEY9ElqloAMZF/a9mz djAe180wfOOHHop0nfx+s/4POis5loyqoPwmx1FSX0PNQ9dIZRjUHHGi/o/aIqQLsicM iNMJhWfW7s+5uxR3L5elhXO84Y4Y4CEWbxtswXODLTQttZQbmQ+KuxnfiHkRQLYm9Qny rR/mNLZu4e573mmLoqkFL6nT/OPiBFsHgW7MlJ+iON0pja8gVR1HrKlnR4070yZlGExR o90N5fCtBMBJ7jYCm19LlZCAF6slZuxbbx+xEoPErJwu+8PvQTvSuLpTRA6hkJEcojbu Im3Q== X-Gm-Message-State: AOAM531AzsUVMOZYOlJ07Bwo7j77TKReaD9OMHitZ+1bUQTa9goyaee8 6wxhAnku0JLry4nqrc3wuGKRfPe0jv0uUJs8HEA= X-Google-Smtp-Source: ABdhPJw/nV+jLQ0fXH4E3IaqEiriaS0Mgkv/6038xCL36trBul0cL4dx0kqCyGT3PjEr2oWDm4RPLeIKlJRSYiyZsZw= X-Received: by 2002:a05:6214:1cc3:b0:443:689a:9b72 with SMTP id g3-20020a0562141cc300b00443689a9b72mr1736474qvd.125.1651828645500; Fri, 06 May 2022 02:17:25 -0700 (PDT) MIME-Version: 1.0 References: <20220506075708.84250-1-haochen.jiang@intel.com> In-Reply-To: From: Uros Bizjak Date: Fri, 6 May 2022 11:17:14 +0200 Message-ID: Subject: Re: [PATCH] Reconstruct i386 testsuite with __builtin_cpu_supports To: Hongyu Wang Cc: Haochen Jiang , Hongtao Liu , "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 09:17:31 -0000 On Fri, May 6, 2022 at 11:00 AM Hongyu Wang wrote: > > > I don't think *_os_support calls should be removed. IIRC, > > __builtin_cpu_supports function checks if the feature is supported by > > CPU, whereas *_os_supports calls check via xgetbv if OS supports > > handling of new registers. > > avx_os_support is like > > avx_os_support (void) > { > unsigned int eax, edx; > unsigned int ecx =3D XCR_XFEATURE_ENABLED_MASK; > > __asm__ ("xgetbv" : "=3Da" (eax), "=3Dd" (edx) : "c" (ecx)); > > return (eax & (XSTATE_SSE | XSTATE_YMM)) =3D=3D (XSTATE_SSE | XSTATE_YM= M); > } > > While in get_avaliable_features we have > > #define XCR_AVX_ENABLED_MASK \ > (XSTATE_SSE | XSTATE_YMM) > if ((ecx & bit_OSXSAVE)) > { > /* Check if XMM, YMM, OPMASK, upper 256 bits of ZMM0-ZMM15 and > ZMM16-ZMM31 states are supported by OSXSAVE. */ > unsigned int xcrlow; > unsigned int xcrhigh; > __asm__ (".byte 0x0f, 0x01, 0xd0" /* xgetbv */ > : "=3Da" (xcrlow), "=3Dd" (xcrhigh) > : "c" (XCR_XFEATURE_ENABLED_MASK)); > if ((xcrlow & XCR_AVX_ENABLED_MASK) =3D=3D XCR_AVX_ENABLED_MASK) > { > avx_usable =3D 1; > > So __builtin_cpu_supports already inherits same check Indeed, thanks for the explanation. OTOH, we don't change the existing tests (perhaps only dg- directives when infrastructure improves), so I would leave the existing testcases as they are. In future, new helper functions should be implemented with __builtin_cpu_supports, but let's leave existing ones as they are. Uros. > Uros Bizjak via Gcc-patches =E4=BA=8E2022=E5=B9= =B45=E6=9C=886=E6=97=A5=E5=91=A8=E4=BA=94 16:27=E5=86=99=E9=81=93=EF=BC=9A > > > > On Fri, May 6, 2022 at 9:57 AM Haochen Jiang = wrote: > > > > > > Hi all, > > > > > > There are some check files in i386 testsuite are written before the f= unction __builtin_cpu_supports is introduced. All of them are using __get_c= puid_count. This patch aims to reconstruct the i386 testsuite with __builti= n_cpu_supports so that we can have a much clearer code. > > > > > > Regtested on x86_64-pc-linux-gnu. Ok for trunk? > > > > I don't think *_os_support calls should be removed. IIRC, > > __builtin_cpu_supports function checks if the feature is supported by > > CPU, whereas *_os_supports calls check via xgetbv if OS supports > > handling of new registers. > > > > Uros. > > > > > > > > Also when writting this patch, I also find some files in testsuite th= at might be useless currently. For example, in the file gcc/testsuite/gcc.t= arget/i386/sse-os-support.h, it always return 1. And there are also some fi= les will no longer be included at all with this patch. Should we remove tho= se files when we have time? > > > > > > BRs, > > > Haochen > > > > > > gcc/testsuite/ChangeLog: > > > > > > * gcc.target/i386/adx-check.h: Change bit check to > > > __builtin_cpu_supports. > > > * gcc.target/i386/aes-avx-check.h: Ditto. > > > * gcc.target/i386/aes-check.h: Ditto. > > > * gcc.target/i386/avx-check.h: Ditto. > > > * gcc.target/i386/avx2-check.h: Ditto. > > > * gcc.target/i386/avx512-check.h: Ditto. > > > * gcc.target/i386/bmi-check.h: Ditto. > > > * gcc.target/i386/bmi2-check.h: Ditto. > > > * gcc.target/i386/f16c-check.h: Ditto. > > > * gcc.target/i386/fma-check.h: Ditto. > > > * gcc.target/i386/fma4-check.h: Ditto. > > > * gcc.target/i386/lzcnt-check.h: Ditto. > > > * gcc.target/i386/mmx-3dnow-check.h: Ditto. > > > * gcc.target/i386/mmx-check.h: Ditto. > > > * gcc.target/i386/pclmul-avx-check.h: Ditto. > > > * gcc.target/i386/pclmul-check.h: Ditto. > > > * gcc.target/i386/rtm-check.h: Ditto. > > > * gcc.target/i386/sha-check.h: Ditto. > > > * gcc.target/i386/sse-check.h: Ditto. > > > * gcc.target/i386/sse2-check.h: Ditto. > > > * gcc.target/i386/sse3-check.h: Ditto. > > > * gcc.target/i386/sse4_1-check.h: Ditto. > > > * gcc.target/i386/sse4_2-check.h: Ditto. > > > * gcc.target/i386/sse4a-check.h: Ditto. > > > * gcc.target/i386/ssse3-check.h: Ditto. > > > * gcc.target/i386/xop-check.h: Ditto. > > > --- > > > gcc/testsuite/gcc.target/i386/adx-check.h | 10 +--- > > > gcc/testsuite/gcc.target/i386/aes-avx-check.h | 14 +---- > > > gcc/testsuite/gcc.target/i386/aes-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/avx-check.h | 12 +--- > > > gcc/testsuite/gcc.target/i386/avx2-check.h | 20 +------ > > > gcc/testsuite/gcc.target/i386/avx512-check.h | 59 +++++++----------= -- > > > gcc/testsuite/gcc.target/i386/bmi-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/bmi2-check.h | 10 +--- > > > gcc/testsuite/gcc.target/i386/f16c-check.h | 10 +--- > > > gcc/testsuite/gcc.target/i386/fma-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/fma4-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/lzcnt-check.h | 11 +--- > > > .../gcc.target/i386/mmx-3dnow-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/mmx-check.h | 11 +--- > > > .../gcc.target/i386/pclmul-avx-check.h | 14 +---- > > > gcc/testsuite/gcc.target/i386/pclmul-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/rtm-check.h | 10 +--- > > > gcc/testsuite/gcc.target/i386/sha-check.h | 10 +--- > > > gcc/testsuite/gcc.target/i386/sse-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/sse2-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/sse3-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/sse4_1-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/sse4_2-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/sse4a-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/ssse3-check.h | 11 +--- > > > gcc/testsuite/gcc.target/i386/xop-check.h | 11 +--- > > > 26 files changed, 73 insertions(+), 272 deletions(-) > > > > > > diff --git a/gcc/testsuite/gcc.target/i386/adx-check.h b/gcc/testsuit= e/gcc.target/i386/adx-check.h > > > index cfed1a38483..bed5dcca385 100644 > > > --- a/gcc/testsuite/gcc.target/i386/adx-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/adx-check.h > > > @@ -1,5 +1,4 @@ > > > #include > > > -#include "cpuid.h" > > > > > > static void adx_test (void); > > > > > > @@ -11,13 +10,8 @@ static void __attribute__ ((noinline)) do_test (vo= id) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run ADX test only if host has ADX support. */ > > > - if (ebx & bit_ADX) > > > + /* Check cpu support for ADX. */ > > > + if (__builtin_cpu_supports ("adx")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/aes-avx-check.h b/gcc/test= suite/gcc.target/i386/aes-avx-check.h > > > index f2a4ead4014..74bf597ead4 100644 > > > --- a/gcc/testsuite/gcc.target/i386/aes-avx-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/aes-avx-check.h > > > @@ -2,8 +2,6 @@ > > > #include > > > #endif > > > #include > > > -#include "cpuid.h" > > > -#include "avx-os-support.h" > > > > > > static void aes_avx_test (void); > > > > > > @@ -17,15 +15,9 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run AES + AVX test only if host has AES + AVX support. */ > > > - if (((ecx & (bit_AVX | bit_OSXSAVE | bit_AES)) > > > - =3D=3D (bit_AVX | bit_OSXSAVE | bit_AES)) > > > - && avx_os_support ()) > > > + /* Check cpu support for AES and AVX. */ > > > + if (__builtin_cpu_supports ("avx") > > > + && __builtin_cpu_supports ("aes")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/aes-check.h b/gcc/testsuit= e/gcc.target/i386/aes-check.h > > > index 7e794423e47..7c3a3b324a7 100644 > > > --- a/gcc/testsuite/gcc.target/i386/aes-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/aes-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void aes_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run AES test only if host has AES support. */ > > > - if (ecx & bit_AES) > > > + /* Check cpu support for AES. */ > > > + if (__builtin_cpu_supports ("aes")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/avx-check.h b/gcc/testsuit= e/gcc.target/i386/avx-check.h > > > index 7ddca9d7b80..4a3dbc257bc 100644 > > > --- a/gcc/testsuite/gcc.target/i386/avx-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/avx-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > -#include "cpuid.h" > > > #include "m256-check.h" > > > -#include "avx-os-support.h" > > > > > > static void avx_test (void); > > > > > > @@ -15,14 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run AVX test only if host has AVX support. */ > > > - if (((ecx & (bit_AVX | bit_OSXSAVE)) =3D=3D (bit_AVX | bit_OSXSAVE= )) > > > - && avx_os_support ()) > > > + /* Check cpu support for AVX. */ > > > + if (__builtin_cpu_supports ("avx")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/avx2-check.h b/gcc/testsui= te/gcc.target/i386/avx2-check.h > > > index 25bed5e0da6..2bc3c4425bb 100644 > > > --- a/gcc/testsuite/gcc.target/i386/avx2-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/avx2-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > -#include "cpuid.h" > > > #include "m256-check.h" > > > -#include "avx-os-support.h" > > > > > > static void avx2_test (void); > > > > > > @@ -10,25 +8,11 @@ static void __attribute__ ((noinline)) do_test (vo= id) > > > avx2_test (); > > > } > > > > > > -static int > > > -check_osxsave (void) > > > -{ > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - __cpuid (1, eax, ebx, ecx, edx); > > > - return (ecx & bit_OSXSAVE) !=3D 0; > > > -} > > > - > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run AVX2 test only if host has AVX2 support. */ > > > - if (check_osxsave () && (ebx & bit_AVX2) && avx_os_support ()) > > > + /* Check cpu support for AVX2. */ > > > + if (__builtin_cpu_supports ("avx2")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/avx512-check.h b/gcc/tests= uite/gcc.target/i386/avx512-check.h > > > index 0ad9064f637..339c79070c9 100644 > > > --- a/gcc/testsuite/gcc.target/i386/avx512-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/avx512-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > -#include "cpuid.h" > > > #include "m512-check.h" > > > -#include "avx512f-os-support.h" > > > > > > #ifndef DO_TEST > > > #define DO_TEST do_test > > > @@ -25,81 +23,66 @@ do_test (void) > > > } > > > #endif > > > > > > -static int > > > -check_osxsave (void) > > > -{ > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - __cpuid (1, eax, ebx, ecx, edx); > > > - return (ecx & bit_OSXSAVE) !=3D 0; > > > -} > > > - > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run AVX512 test only if host has ISA support. */ > > > - if (check_osxsave () > > > - && (ebx & bit_AVX512F) > > > + /* Check cpu support for AVX512. */ > > > + if (__builtin_cpu_supports ("avx512f") > > > #ifdef AVX512VL > > > - && (ebx & bit_AVX512VL) > > > + && __builtin_cpu_supports ("avx512vl") > > > #endif > > > #ifdef AVX512ER > > > - && (ebx & bit_AVX512ER) > > > + && __builtin_cpu_supports ("avx512er") > > > #endif > > > #ifdef AVX512CD > > > - && (ebx & bit_AVX512CD) > > > + && __builtin_cpu_supports ("avx512cd") > > > #endif > > > #ifdef AVX512DQ > > > - && (ebx & bit_AVX512DQ) > > > + && __builtin_cpu_supports ("avx512dq") > > > #endif > > > #ifdef AVX512BW > > > - && (ebx & bit_AVX512BW) > > > + && __builtin_cpu_supports ("avx512bw") > > > #endif > > > #ifdef AVX512IFMA > > > - && (ebx & bit_AVX512IFMA) > > > + && __builtin_cpu_supports ("avx512ifma") > > > #endif > > > #ifdef AVX512VBMI > > > - && (ecx & bit_AVX512VBMI) > > > + && __builtin_cpu_supports ("avx512vbmi") > > > #endif > > > #ifdef AVX5124FMAPS > > > - && (edx & bit_AVX5124FMAPS) > > > + && __builtin_cpu_supports ("avx5124fmaps") > > > #endif > > > #ifdef AVX5124VNNIW > > > - && (edx & bit_AVX5124VNNIW) > > > + && __builtin_cpu_supports ("avx5124vnniw") > > > #endif > > > #ifdef AVX512VPOPCNTDQ > > > - && (ecx & bit_AVX512VPOPCNTDQ) > > > + && __builtin_cpu_supports ("avx512vpopcntdq") > > > #endif > > > #ifdef AVX512BITALG > > > - && (ecx & bit_AVX512BITALG) > > > + && __builtin_cpu_supports ("avx512bitalg") > > > #endif > > > #ifdef GFNI > > > - && (ecx & bit_GFNI) > > > + && __builtin_cpu_supports ("gfni") > > > #endif > > > #ifdef AVX512VBMI2 > > > - && (ecx & bit_AVX512VBMI2) > > > + && __builtin_cpu_supports ("avx512vbmi2") > > > #endif > > > #ifdef AVX512VNNI > > > - && (ecx & bit_AVX512VNNI) > > > + && __builtin_cpu_supports ("avx512vnni") > > > #endif > > > #ifdef AVX512FP16 > > > - && (edx & bit_AVX512FP16) > > > + && __builtin_cpu_supports ("avx512fp16") > > > #endif > > > #ifdef VAES > > > - && (ecx & bit_VAES) > > > + && __builtin_cpu_supports ("vaes") > > > #endif > > > #ifdef VPCLMULQDQ > > > - && (ecx & bit_VPCLMULQDQ) > > > + && __builtin_cpu_supports ("vpclmulqdq") > > > #endif > > > #ifdef AVX512VP2INTERSECT > > > - && (edx & bit_AVX512VP2INTERSECT) > > > + && __builtin_cpu_supports ("avx512vp2intersect") > > > #endif > > > - && avx512f_os_support ()) > > > + ) > > > { > > > DO_TEST (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/bmi-check.h b/gcc/testsuit= e/gcc.target/i386/bmi-check.h > > > index 1973f3b6468..6af0291a947 100644 > > > --- a/gcc/testsuite/gcc.target/i386/bmi-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/bmi-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void bmi_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run BMI test only if host has BMI support. */ > > > - if (ebx & bit_BMI) > > > + /* Check cpu support for BMI. */ > > > + if (__builtin_cpu_supports ("bmi")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/bmi2-check.h b/gcc/testsui= te/gcc.target/i386/bmi2-check.h > > > index ba91ef9b780..75c4d8d9616 100644 > > > --- a/gcc/testsuite/gcc.target/i386/bmi2-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/bmi2-check.h > > > @@ -1,6 +1,5 @@ > > > #include > > > #include > > > -#include "cpuid.h" > > > > > > static void bmi2_test (void); > > > > > > @@ -14,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run BMI2 test only if host has BMI2 support. */ > > > - if (ebx & bit_BMI2) > > > + /* Check cpu support for BMI2. */ > > > + if (__builtin_cpu_supports ("bmi2")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/f16c-check.h b/gcc/testsui= te/gcc.target/i386/f16c-check.h > > > index af7f32c5f4f..2cbf34ab516 100644 > > > --- a/gcc/testsuite/gcc.target/i386/f16c-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/f16c-check.h > > > @@ -1,6 +1,5 @@ > > > #include > > > #include > > > -#include "cpuid.h" > > > #include "m256-check.h" > > > > > > static void f16c_test (void); > > > @@ -8,13 +7,8 @@ static void f16c_test (void); > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run F16C test only if host has F16C support. */ > > > - if (ecx & bit_F16C) > > > + /* Check cpu support for F16C. */ > > > + if (__builtin_cpu_supports ("f16c")) > > > { > > > f16c_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/fma-check.h b/gcc/testsuit= e/gcc.target/i386/fma-check.h > > > index 8390f5088bd..6c1d3372218 100644 > > > --- a/gcc/testsuite/gcc.target/i386/fma-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/fma-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void fma_test (void); > > > > > > static void __attribute__ ((noinline)) do_test (void) > > > @@ -12,13 +10,8 @@ static void __attribute__ ((noinline)) do_test (vo= id) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run FMA test only if host has FMA support. */ > > > - if (ecx & bit_FMA) > > > + /* Check cpu support for FMA. */ > > > + if (__builtin_cpu_supports ("fma")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/fma4-check.h b/gcc/testsui= te/gcc.target/i386/fma4-check.h > > > index 33cd9628c04..2d2c2718029 100644 > > > --- a/gcc/testsuite/gcc.target/i386/fma4-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/fma4-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void fma4_test (void); > > > > > > static void > > > @@ -14,13 +12,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (0x80000001, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run FMA4 test only if host has FMA4 support. */ > > > - if (ecx & bit_FMA4) > > > + /* Check cpu support foe FMA4. */ > > > + if (__builtin_cpu_supports ("fma4")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/lzcnt-check.h b/gcc/testsu= ite/gcc.target/i386/lzcnt-check.h > > > index 8aad834d6af..824f1a3b513 100644 > > > --- a/gcc/testsuite/gcc.target/i386/lzcnt-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/lzcnt-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void lzcnt_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (0x80000001, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run LZCNT test only if host has LZCNT support. */ > > > - if (ecx & bit_LZCNT) > > > + /* Check cpu support for LZCNT. */ > > > + if (__builtin_cpu_supports ("lzcnt")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/mmx-3dnow-check.h b/gcc/te= stsuite/gcc.target/i386/mmx-3dnow-check.h > > > index 4f2f7f3ac40..0ec2dca2e19 100644 > > > --- a/gcc/testsuite/gcc.target/i386/mmx-3dnow-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/mmx-3dnow-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void mmx_3dnow_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (0x80000001, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run 3DNow! test only if host has 3DNow! support. */ > > > - if (edx & bit_3DNOW) > > > + /* Check cpu support for 3DNow!. */ > > > + if (__builtin_cpu_supports ("3dnow")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/mmx-check.h b/gcc/testsuit= e/gcc.target/i386/mmx-check.h > > > index faf9b876f38..2afe5183ba2 100644 > > > --- a/gcc/testsuite/gcc.target/i386/mmx-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/mmx-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void mmx_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run MMX test only if host has MMX support. */ > > > - if (edx & bit_MMX) > > > + /* Check cpu support for MMX. */ > > > + if (__builtin_cpu_supports ("mmx")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/pclmul-avx-check.h b/gcc/t= estsuite/gcc.target/i386/pclmul-avx-check.h > > > index 5eed2e2203c..b506b3306e6 100644 > > > --- a/gcc/testsuite/gcc.target/i386/pclmul-avx-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/pclmul-avx-check.h > > > @@ -2,8 +2,6 @@ > > > #include > > > #endif > > > #include > > > -#include "cpuid.h" > > > -#include "avx-os-support.h" > > > > > > static void pclmul_avx_test (void); > > > > > > @@ -17,15 +15,9 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run PCLMUL + AVX test only if host has PCLMUL + AVX support. *= / > > > - if (((ecx & (bit_AVX | bit_OSXSAVE | bit_PCLMUL)) > > > - =3D=3D (bit_AVX | bit_OSXSAVE | bit_PCLMUL)) > > > - && avx_os_support ()) > > > + /* Check cpu support for PCLMUL and AVX. */ > > > + if (__builtin_cpu_supports ("pclmul") > > > + && __builtin_cpu_supports ("avx")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/pclmul-check.h b/gcc/tests= uite/gcc.target/i386/pclmul-check.h > > > index 7526cbe2ddf..3ed1a044627 100644 > > > --- a/gcc/testsuite/gcc.target/i386/pclmul-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/pclmul-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void pclmul_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run PCLMULQDQ test only if host has PCLMULQDQ support. */ > > > - if (ecx & bit_PCLMUL) > > > + /* Check cpu support for PCLMUL. */ > > > + if (__builtin_cpu_supports ("pclmul")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/rtm-check.h b/gcc/testsuit= e/gcc.target/i386/rtm-check.h > > > index bdb5a6dc0bf..4121e602a7f 100644 > > > --- a/gcc/testsuite/gcc.target/i386/rtm-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/rtm-check.h > > > @@ -1,5 +1,4 @@ > > > #include > > > -#include "cpuid.h" > > > > > > static void rtm_test (void); > > > > > > @@ -11,13 +10,8 @@ static void __attribute__ ((noinline)) do_test (vo= id) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run RTM test only if host has RTM support. */ > > > - if (ebx & bit_RTM) > > > + /* Check cpu support for RTM. */ > > > + if (__builtin_cpu_supports ("rtm")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/sha-check.h b/gcc/testsuit= e/gcc.target/i386/sha-check.h > > > index 5bc5a59ab80..61ce43053f9 100644 > > > --- a/gcc/testsuite/gcc.target/i386/sha-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/sha-check.h > > > @@ -1,5 +1,4 @@ > > > #include > > > -#include "cpuid.h" > > > > > > static void sha_test (void); > > > > > > @@ -13,13 +12,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SHA test only if host has SHA support. */ > > > - if (ebx & bit_SHA) > > > + /* Check cpu support for SHA. */ > > > + if (__builtin_cpu_supports ("sha")) > > > { > > > do_test (); > > > #ifdef DEBUG > > > diff --git a/gcc/testsuite/gcc.target/i386/sse-check.h b/gcc/testsuit= e/gcc.target/i386/sse-check.h > > > index 11b71bc3e97..58bc88c5598 100644 > > > --- a/gcc/testsuite/gcc.target/i386/sse-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/sse-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > #include "m128-check.h" > > > -#include "cpuid.h" > > > -#include "sse-os-support.h" > > > > > > static void sse_test (void); > > > > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SSE test only if host has SSE support. */ > > > - if ((edx & bit_SSE) && sse_os_support ()) > > > + /* Check cpu support for SSE. */ > > > + if (__builtin_cpu_supports ("sse")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/sse2-check.h b/gcc/testsui= te/gcc.target/i386/sse2-check.h > > > index fd4a6ce1dbf..4976a27022d 100644 > > > --- a/gcc/testsuite/gcc.target/i386/sse2-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/sse2-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > -#include "cpuid.h" > > > #include "m128-check.h" > > > -#include "sse-os-support.h" > > > > > > static void sse2_test (void); > > > > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SSE2 test only if host has SSE2 support. */ > > > - if ((edx & bit_SSE2) && sse_os_support ()) > > > + /* Check cpu support for SSE2. */ > > > + if (__builtin_cpu_supports ("sse2")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/sse3-check.h b/gcc/testsui= te/gcc.target/i386/sse3-check.h > > > index 5a0a0b1a02e..3c58361e925 100644 > > > --- a/gcc/testsuite/gcc.target/i386/sse3-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/sse3-check.h > > > @@ -1,7 +1,5 @@ > > > #include > > > #include > > > -#include "cpuid.h" > > > -#include "sse-os-support.h" > > > > > > static void sse3_test (void); > > > > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SSE3 test only if host has SSE3 support. */ > > > - if ((ecx & bit_SSE3) && sse_os_support ()) > > > + /* Check cpu support for SSE3. */ > > > + if (__builtin_cpu_supports ("sse3")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/sse4_1-check.h b/gcc/tests= uite/gcc.target/i386/sse4_1-check.h > > > index 788f65d61cb..61d0d0284a8 100644 > > > --- a/gcc/testsuite/gcc.target/i386/sse4_1-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/sse4_1-check.h > > > @@ -1,6 +1,4 @@ > > > #include > > > - > > > -#include "cpuid.h" > > > #include "m128-check.h" > > > > > > static void sse4_1_test (void); > > > @@ -17,13 +15,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SSE4.1 test only if host has SSE4.1 support. */ > > > - if (ecx & bit_SSE4_1) > > > + /* Check cpu support for SSE4.1. */ > > > + if (__builtin_cpu_supports ("sse4.1")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/sse4_2-check.h b/gcc/tests= uite/gcc.target/i386/sse4_2-check.h > > > index c33cd1b4986..6c921ac52c7 100644 > > > --- a/gcc/testsuite/gcc.target/i386/sse4_2-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/sse4_2-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > - > > > #include "m128-check.h" > > > -#include "cpuid.h" > > > > > > static void sse4_2_test (void); > > > > > > @@ -16,13 +14,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SSE4.2 test only if host has SSE4.2 support. */ > > > - if (ecx & bit_SSE4_2) > > > + /* Check cpu support for SSE4.2. */ > > > + if (__builtin_cpu_supports ("sse4.2")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/sse4a-check.h b/gcc/testsu= ite/gcc.target/i386/sse4a-check.h > > > index d43b4b222b1..ae70ff0a268 100644 > > > --- a/gcc/testsuite/gcc.target/i386/sse4a-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/sse4a-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void sse4a_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (0x80000001, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SSE4a test only if host has SSE4a support. */ > > > - if (ecx & bit_SSE4a) > > > + /* Check cpu support for SSE4a. */ > > > + if (__builtin_cpu_supports ("sse4a")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/ssse3-check.h b/gcc/testsu= ite/gcc.target/i386/ssse3-check.h > > > index 3ca79333c7f..3e834811f2d 100644 > > > --- a/gcc/testsuite/gcc.target/i386/ssse3-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/ssse3-check.h > > > @@ -1,8 +1,6 @@ > > > #include > > > #include > > > > > > -#include "cpuid.h" > > > - > > > static void ssse3_test (void); > > > > > > static void > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run SSSE3 test only if host has SSSE3 support. */ > > > - if (ecx & bit_SSSE3) > > > + /* Check cpu support for SSSE3. */ > > > + if (__builtin_cpu_supports ("ssse3")) > > > do_test (); > > > > > > return 0; > > > diff --git a/gcc/testsuite/gcc.target/i386/xop-check.h b/gcc/testsuit= e/gcc.target/i386/xop-check.h > > > index 395abe8766d..e1ef1273111 100644 > > > --- a/gcc/testsuite/gcc.target/i386/xop-check.h > > > +++ b/gcc/testsuite/gcc.target/i386/xop-check.h > > > @@ -1,6 +1,4 @@ > > > #include > > > - > > > -#include "cpuid.h" > > > #include "m256-check.h" > > > > > > static void xop_test (void); > > > @@ -15,13 +13,8 @@ do_test (void) > > > int > > > main () > > > { > > > - unsigned int eax, ebx, ecx, edx; > > > - > > > - if (!__get_cpuid (0x80000001, &eax, &ebx, &ecx, &edx)) > > > - return 0; > > > - > > > - /* Run XOP test only if host has XOP support. */ > > > - if (ecx & bit_XOP) > > > + /* Check cpu support for XOP. */ > > > + if (__builtin_cpu_supports ("xop")) > > > do_test (); > > > > > > return 0; > > > -- > > > 2.18.1 > > >