From 2c12f2f4d454249800acbbb23784398cf5ce34d2 Mon Sep 17 00:00:00 2001 From: Ilya Tocar Date: Tue, 16 Sep 2014 11:57:56 +0000 Subject: [PATCH] driver-i386.c (host_detect_local_cpu): Detect lack of zmm/k regs support. gcc/ 2014-09-16 Ilya Tocar * config/i386/driver-i386.c (host_detect_local_cpu): Detect lack of zmm/k regs support. testsuite/ 2014-09-16 Ilya Tocar * gcc.target/i386/avx512f-os-support.h: Remove magic number. From-SVN: r215297 --- gcc/ChangeLog | 5 +++++ gcc/config/i386/driver-i386.c | 17 +++++++++++++++++ gcc/testsuite/ChangeLog | 4 ++++ .../gcc.target/i386/avx512f-os-support.h | 17 +++++++++++++++-- 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4ba66a70b4e..d446d2cd2de 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2014-09-16 Ilya Tocar + + * config/i386/driver-i386.c (host_detect_local_cpu): Detect lack of + zmm/k regs support. + 2014-09-16 Alexander Ivchenko Maxim Kuznetsov Anna Tikhonova diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c index af3088e5b4b..4d6bf832f46 100644 --- a/gcc/config/i386/driver-i386.c +++ b/gcc/config/i386/driver-i386.c @@ -533,6 +533,9 @@ const char *host_detect_local_cpu (int argc, const char **argv) #define XSTATE_FP 0x1 #define XSTATE_SSE 0x2 #define XSTATE_YMM 0x4 +#define XSTATE_OPMASK 0x20 +#define XSTATE_ZMM 0x40 +#define XSTATE_HI_ZMM 0x80 if (has_osxsave) asm (".byte 0x0f; .byte 0x01; .byte 0xd0" : "=a" (eax), "=d" (edx) @@ -554,6 +557,20 @@ const char *host_detect_local_cpu (int argc, const char **argv) has_xsavec = 0; } + if (!has_osxsave + || (eax & + (XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK | XSTATE_ZMM | XSTATE_HI_ZMM)) + != (XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK | XSTATE_ZMM | XSTATE_HI_ZMM)) + { + has_avx512f = 0; + has_avx512er = 0; + has_avx512pf = 0; + has_avx512cd = 0; + has_avx512dq = 0; + has_avx512bw = 0; + has_avx512vl = 0; + } + if (!arch) { if (vendor == signature_AMD_ebx diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4d3c96beee2..c3593a710c4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-09-16 Ilya Tocar + + * gcc.target/i386/avx512f-os-support.h: Remove magic number. + 2014-09-16 Jakub Jelinek PR fortran/56408 diff --git a/gcc/testsuite/gcc.target/i386/avx512f-os-support.h b/gcc/testsuite/gcc.target/i386/avx512f-os-support.h index deefa5e1105..2f1ed03df45 100644 --- a/gcc/testsuite/gcc.target/i386/avx512f-os-support.h +++ b/gcc/testsuite/gcc.target/i386/avx512f-os-support.h @@ -1,10 +1,23 @@ /* Check if the OS supports executing AVX512F instructions. */ +#define XCR_XFEATURE_ENABLED_MASK 0x0 + +#define XSTATE_FP 0x1 +#define XSTATE_SSE 0x2 +#define XSTATE_YMM 0x4 +#define XSTATE_OPMASK 0x20 +#define XSTATE_ZMM 0x40 +#define XSTATE_HI_ZMM 0x80 + static int avx512f_os_support (void) { unsigned int eax, edx; + unsigned int ecx = XCR_XFEATURE_ENABLED_MASK; + unsigned int mask = XSTATE_SSE | XSTATE_YMM | XSTATE_OPMASK + | XSTATE_ZMM | XSTATE_HI_ZMM; + + __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (ecx)); - __asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0)); - return (eax & 230) == 230; + return ((eax & mask) == mask); } -- 2.30.2