From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by sourceware.org (Postfix) with ESMTPS id 5A3853858401 for ; Fri, 6 May 2022 08:27:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A3853858401 Received: by mail-qt1-x829.google.com with SMTP id e15so5407689qtp.3 for ; Fri, 06 May 2022 01:27:00 -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=fz/jFXljMBi2Fgof8f73BQoqKZ/pozJck7NgIOBe5Hw=; b=A38j+bcAQbSgB/Xz5iyvzH1MyFyvZRj09juLbpCXnIFIMWXjF8VEtcy93Bg+qXBpjL m5AoRrMRP741qy7XwbbP3+YAKa+xMQ1gMTgSOP7X1VilKYXHRZw0T3rhGsDWS5sdJH2k lI8r+oLG9ERRecWgKQzcQmg5n3f+YlC8Qps2kA23dluQYxURt6n/Oood3gsNFDqk8tHB HvcWepzfBmHSUOPjppnhXV78ggiINOGV8xtWOfCA3AW0Fwhb3Ih6kU0rV+sPmu9bi/I8 WNwQeEHeBFrZ6HOWurtm4rqwoeZ3pHMqGV/ZgK9mdlNDV32Ur8kVhRxSgNwSyDsPSomL fkbg== X-Gm-Message-State: AOAM531pdtKEuqgaG/Xg6cgpTu3duKyb7jEfR0A5gXdbi0S+Xowb+yyB biTFFdUcB2BKXQOi6p6pbY2cgg6rv9doy5U/AB4= X-Google-Smtp-Source: ABdhPJy2ekjt8Nzx3VskkrnDl+8obNT63qbZ1dYIHhAuPsNHoQsRT6erfOVTAByfmje/adRl8dliCVQnomT+8c9Hxac= X-Received: by 2002:ac8:574d:0:b0:2f3:b4aa:700f with SMTP id 13-20020ac8574d000000b002f3b4aa700fmr1730359qtx.54.1651825619202; Fri, 06 May 2022 01:26:59 -0700 (PDT) MIME-Version: 1.0 References: <20220506075708.84250-1-haochen.jiang@intel.com> In-Reply-To: <20220506075708.84250-1-haochen.jiang@intel.com> From: Uros Bizjak Date: Fri, 6 May 2022 10:26:48 +0200 Message-ID: Subject: Re: [PATCH] Reconstruct i386 testsuite with __builtin_cpu_supports To: Haochen Jiang Cc: "gcc-patches@gcc.gnu.org" , Hongtao Liu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.8 required=5.0 tests=BAYES_00, 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 08:27:04 -0000 On Fri, May 6, 2022 at 9:57 AM Haochen Jiang wrot= e: > > Hi all, > > There are some check files in i386 testsuite are written before the funct= ion __builtin_cpu_supports is introduced. All of them are using __get_cpuid= _count. This patch aims to reconstruct the i386 testsuite with __builtin_cp= u_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 that m= ight be useless currently. For example, in the file gcc/testsuite/gcc.targe= t/i386/sse-os-support.h, it always return 1. And there are also some files = will no longer be included at all with this patch. Should we remove those f= iles 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/testsuite/gc= c.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 (void) > 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/testsuit= e/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/testsuite/gc= c.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/testsuite/gc= c.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/testsuite/g= cc.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 (void) > 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/testsuite= /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/testsuite/gc= c.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/testsuite/g= cc.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/testsuite/g= cc.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/testsuite/gc= c.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 (void) > 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/testsuite/g= cc.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/testsuite/= 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/testsu= ite/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/testsuite/gc= c.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/tests= uite/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/testsuite= /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/testsuite/gc= c.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 (void) > 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/testsuite/gc= c.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/testsuite/gc= c.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/testsuite/g= cc.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/testsuite/g= cc.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/testsuite= /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/testsuite= /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/testsuite/= 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/testsuite/= 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/testsuite/gc= c.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 >