From: Ilya Tocar Date: Thu, 27 Nov 2014 13:51:10 +0000 (+0000) Subject: Support avx512f in __builtin_cpu_supports. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c17eac85616572b7e1163cfb87d95a7875c89407;p=gcc.git Support avx512f in __builtin_cpu_supports. gcc/ * config/i386/cpuid.h (bit_MPX, bit_BNDREGS, bit_BNDCSR): Define. * config/i386/i386.c (get_builtin_code_for_version): Add avx512f. (fold_builtin_cpu): Ditto. * doc/extend.texi: Documment it. gcc/testsuite/ * g++.dg/ext/mv2.C: Add test for target ("avx512f"). * gcc.target/i386/builtin_target.c: Ditto. libgcc/ * config/i386/cpuinfo.c (processor_features): Add FEATURE_AVX512F. * config/i386/cpuinfo.c (get_available_features): Detect it. From-SVN: r218125 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aa3aa237957..4abbd35c518 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-11-27 Ilya Tocar + + * config/i386/cpuid.h (bit_MPX, bit_BNDREGS, bit_BNDCSR): + Define. + * config/i386/i386.c (get_builtin_code_for_version): Add avx512f. + (fold_builtin_cpu): Ditto. + * doc/extend.texi: Documment it. + 2014-11-27 Jakub Jelinek PR middle-end/64067 diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index 6c6e7f34acf..e3b76465b95 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -72,6 +72,7 @@ #define bit_AVX2 (1 << 5) #define bit_BMI2 (1 << 8) #define bit_RTM (1 << 11) +#define bit_MPX (1 << 14) #define bit_AVX512F (1 << 16) #define bit_AVX512DQ (1 << 17) #define bit_RDSEED (1 << 18) @@ -91,6 +92,10 @@ #define bit_PREFETCHWT1 (1 << 0) #define bit_AVX512VBMI (1 << 1) +/* XFEATURE_ENABLED_MASK register bits (%eax == 13, %ecx == 0) */ +#define bit_BNDREGS (1 << 3) +#define bit_BNDCSR (1 << 4) + /* Extended State Enumeration Sub-leaf (%eax == 13, %ecx == 1) */ #define bit_XSAVEOPT (1 << 0) #define bit_XSAVEC (1 << 1) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index eafc15a84a3..24931309ea0 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -34235,7 +34235,8 @@ get_builtin_code_for_version (tree decl, tree *predicate_list) P_FMA, P_PROC_FMA, P_AVX2, - P_PROC_AVX2 + P_PROC_AVX2, + P_AVX512F }; enum feature_priority priority = P_ZERO; @@ -34263,7 +34264,8 @@ get_builtin_code_for_version (tree decl, tree *predicate_list) {"fma4", P_FMA4}, {"xop", P_XOP}, {"fma", P_FMA}, - {"avx2", P_AVX2} + {"avx2", P_AVX2}, + {"avx512f", P_AVX512F} }; @@ -35238,6 +35240,7 @@ fold_builtin_cpu (tree fndecl, tree *args) F_FMA4, F_XOP, F_FMA, + F_AVX512F, F_MAX }; @@ -35326,7 +35329,8 @@ fold_builtin_cpu (tree fndecl, tree *args) {"fma4", F_FMA4}, {"xop", F_XOP}, {"fma", F_FMA}, - {"avx2", F_AVX2} + {"avx2", F_AVX2}, + {"avx512f",F_AVX512F} }; tree __processor_model_type = build_processor_model_struct (); diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 7178c9a7e8e..773e14ce6b2 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -11642,6 +11642,8 @@ SSE4.2 instructions. AVX instructions. @item avx2 AVX2 instructions. +@item avx512f +AVX512F instructions. @end table Here is an example: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 86af18c6c85..25928353900 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-11-27 Ilya Tocar + + * g++.dg/ext/mv2.C: Add test for target ("avx512f"). + * gcc.target/i386/builtin_target.c: Ditto. + 2014-11-27 Kai Tietz PR c++/63904 diff --git a/gcc/testsuite/g++.dg/ext/mv2.C b/gcc/testsuite/g++.dg/ext/mv2.C index 869e99b4fae..d4f1f92c611 100644 --- a/gcc/testsuite/g++.dg/ext/mv2.C +++ b/gcc/testsuite/g++.dg/ext/mv2.C @@ -20,31 +20,34 @@ int foo () __attribute__ ((target ("sse4.2"))); int foo () __attribute__ ((target ("popcnt"))); int foo () __attribute__ ((target ("avx"))); int foo () __attribute__ ((target ("avx2"))); +int foo () __attribute__ ((target ("avx512f"))); int main () { int val = foo (); - if (__builtin_cpu_supports ("avx2")) - assert (val == 1); + if (__builtin_cpu_supports ("avx512f")) + assert (val == 11); + else if (__builtin_cpu_supports ("avx2")) + assert (val == 10); else if (__builtin_cpu_supports ("avx")) - assert (val == 2); + assert (val == 9); else if (__builtin_cpu_supports ("popcnt")) - assert (val == 3); + assert (val == 8); else if (__builtin_cpu_supports ("sse4.2")) - assert (val == 4); + assert (val == 7); else if (__builtin_cpu_supports ("sse4.1")) - assert (val == 5); - else if (__builtin_cpu_supports ("ssse3")) assert (val == 6); + else if (__builtin_cpu_supports ("ssse3")) + assert (val == 5); else if (__builtin_cpu_supports ("sse3")) - assert (val == 7); + assert (val == 4); else if (__builtin_cpu_supports ("sse2")) - assert (val == 8); + assert (val == 3); else if (__builtin_cpu_supports ("sse")) - assert (val == 9); + assert (val == 2); else if (__builtin_cpu_supports ("mmx")) - assert (val == 10); + assert (val == 1); else assert (val == 0); @@ -60,59 +63,65 @@ foo () int __attribute__ ((target("mmx"))) foo () { - return 10; + return 1; } int __attribute__ ((target("sse"))) foo () { - return 9; + return 2; } int __attribute__ ((target("sse2"))) foo () { - return 8; + return 3; } int __attribute__ ((target("sse3"))) foo () { - return 7; + return 4; } int __attribute__ ((target("ssse3"))) foo () { - return 6; + return 5; } int __attribute__ ((target("sse4.1"))) foo () { - return 5; + return 6; } int __attribute__ ((target("sse4.2"))) foo () { - return 4; + return 7; } int __attribute__ ((target("popcnt"))) foo () { - return 3; + return 8; } int __attribute__ ((target("avx"))) foo () { - return 2; + return 9; } int __attribute__ ((target("avx2"))) foo () { - return 1; + return 10; +} + +int __attribute__ ((target("avx512f"))) +foo () +{ + return 11; } diff --git a/gcc/testsuite/gcc.target/i386/builtin_target.c b/gcc/testsuite/gcc.target/i386/builtin_target.c index c40983e6b3c..b6a3eee1c8b 100644 --- a/gcc/testsuite/gcc.target/i386/builtin_target.c +++ b/gcc/testsuite/gcc.target/i386/builtin_target.c @@ -145,6 +145,8 @@ check_features (unsigned int ecx, unsigned int edx, __cpuid_count (7, 0, eax, ebx, ecx, edx); if (ebx & bit_AVX2) assert (__builtin_cpu_supports ("avx2")); + if (ebx & bit_AVX512F) + assert (__builtin_cpu_supports ("avx512f")); } } @@ -241,6 +243,8 @@ quick_check () assert (__builtin_cpu_supports ("avx2") >= 0); + assert (__builtin_cpu_supports ("avx512f") >= 0); + /* Check CPU type. */ assert (__builtin_cpu_is ("amd") >= 0); diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index ea3fdc87845..16114a7471e 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2014-11-27 Ilya Tocar + + * config/i386/cpuinfo.c (processor_features): Add FEATURE_AVX512F. + * config/i386/cpuinfo.c (get_available_features): Detect it. + 2014-11-27 Tony Wang * config/arm/lib1funcs.S (FUNC_START): Add conditional section diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c index 6ff7502bb9a..8ca385cb977 100644 --- a/libgcc/config/i386/cpuinfo.c +++ b/libgcc/config/i386/cpuinfo.c @@ -96,7 +96,8 @@ enum processor_features FEATURE_SSE4_A, FEATURE_FMA4, FEATURE_XOP, - FEATURE_FMA + FEATURE_FMA, + FEATURE_AVX512F }; struct __processor_model @@ -278,6 +279,8 @@ get_available_features (unsigned int ecx, unsigned int edx, __cpuid_count (7, 0, eax, ebx, ecx, edx); if (ebx & bit_AVX2) features |= (1 << FEATURE_AVX2); + if (ebx & bit_AVX512F) + features |= (1 << FEATURE_AVX512F); } unsigned int ext_level;