aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2011-10-21 16:32:32 +0200
committerUros Bizjak <uros@gcc.gnu.org>2011-10-21 16:32:32 +0200
commit2c9b39efcb20aa2a89aff9676a236f9582d5a952 (patch)
tree906548e4c4bcac8510b1b1db6cb32e633abbc935
parente2724e63c6d26b05a51a519f4715265e8c82419a (diff)
downloadgcc-2c9b39efcb20aa2a89aff9676a236f9582d5a952.zip
gcc-2c9b39efcb20aa2a89aff9676a236f9582d5a952.tar.gz
gcc-2c9b39efcb20aa2a89aff9676a236f9582d5a952.tar.bz2
re PR driver/50740 (CPUID leaf 7 for BMI/BMI2/AVX2 feature detection not qualified with max_level and doesn't use subleaf)
PR target/50740 * config/i386/driver-i386.c (host_detect_local_cpu): Do cpuid 7 only if max_level allows that. testsuite/ChangeLog: PR target/50740 * gcc.target/i386/avx2-check.h (main): Check CPUID level correctly. * gcc.target/i386/bmi2-check.h: Ditto. From-SVN: r180304
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/config/i386/driver-i386.c15
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/i386/avx2-check.h3
-rw-r--r--gcc/testsuite/gcc.target/i386/bmi2-check.h3
5 files changed, 30 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 16da4d6..86658cb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-21 H.J. Lu <hongjiu.lu@intel.com>
+ Kirill Yukhin <kirill.yukhin@intel.com>
+
+ * config/i386/driver-i386.c (host_detect_local_cpu): Do cpuid 7 only
+ if max_level allows that.
+
2011-10-21 Bernd Schmidt <bernds@codesourcery.com>
* reg-notes.def (DEP_CONTROL): New.
@@ -117,7 +123,8 @@
2011-10-21 Jan Hubicka <jh@suse.cz>
* cgraph.c (dump_cgraph_node): Dump alias flag.
- * cgraphunit.c (handle_alias_pairs): Handle weakrefs with no destination.
+ * cgraphunit.c (handle_alias_pairs): Handle weakrefs with
+ no destination.
(get_alias_symbol): New function.
(output_weakrefs): Output also weakrefs with no destinatoin.
(lto_output_node): Output weakref alias flag when at function boundary.
@@ -125,7 +132,6 @@
2011-10-21 Andrew Stubbs <ams@codesourcery.com>
PR target/50809
-
* config/arm/driver-arm.c (vendors): Make static.
2011-10-21 Uros Bizjak <ubizjak@gmail.com>
diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c
index 8107ece..5f14c76 100644
--- a/gcc/config/i386/driver-i386.c
+++ b/gcc/config/i386/driver-i386.c
@@ -451,6 +451,15 @@ const char *host_detect_local_cpu (int argc, const char **argv)
has_sse = edx & bit_SSE;
has_sse2 = edx & bit_SSE2;
+ if (max_level >= 7)
+ {
+ __cpuid_count (7, 0, eax, ebx, ecx, edx);
+
+ has_bmi = ebx & bit_BMI;
+ has_avx2 = ebx & bit_AVX2;
+ has_bmi2 = ebx & bit_BMI2;
+ }
+
/* Check cpuid level of extended features. */
__cpuid (0x80000000, ext_level, ebx, ecx, edx);
@@ -470,12 +479,6 @@ const char *host_detect_local_cpu (int argc, const char **argv)
has_longmode = edx & bit_LM;
has_3dnowp = edx & bit_3DNOWP;
has_3dnow = edx & bit_3DNOW;
-
- __cpuid (0x7, eax, ebx, ecx, edx);
-
- has_bmi = ebx & bit_BMI;
- has_avx2 = ebx & bit_AVX2;
- has_bmi2 = ebx & bit_BMI2;
}
if (!arch)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a1b2752..ef34046 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-21 H.J. Lu <hongjiu.lu@intel.com>
+ Kirill Yukhin <kirill.yukhin@intel.com>
+
+ PR target/50740
+ * gcc.target/i386/avx2-check.h (main): Check CPUID level correctly.
+ * gcc.target/i386/bmi2-check.h: Ditto.
+
2011-10-21 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/50811
diff --git a/gcc/testsuite/gcc.target/i386/avx2-check.h b/gcc/testsuite/gcc.target/i386/avx2-check.h
index 22c9b39..424335d 100644
--- a/gcc/testsuite/gcc.target/i386/avx2-check.h
+++ b/gcc/testsuite/gcc.target/i386/avx2-check.h
@@ -21,6 +21,9 @@ main ()
/* Run AVX2 test only if host has AVX2 support. */
if ((ecx & bit_OSXSAVE) == (bit_OSXSAVE))
{
+ if (__get_cpuid_max (0, NULL) < 7)
+ return 0;
+
__cpuid_count (7, 0, eax, ebx, ecx, edx);
if ((avx_os_support ()) && ((ebx & bit_AVX2) == bit_AVX2))
diff --git a/gcc/testsuite/gcc.target/i386/bmi2-check.h b/gcc/testsuite/gcc.target/i386/bmi2-check.h
index 5ffce44..c933a49 100644
--- a/gcc/testsuite/gcc.target/i386/bmi2-check.h
+++ b/gcc/testsuite/gcc.target/i386/bmi2-check.h
@@ -17,6 +17,9 @@ main ()
{
unsigned int eax, ebx, ecx, edx;
+ if (__get_cpuid_max (0, NULL) < 7)
+ return 0;
+
__cpuid_count (7, 0, eax, ebx, ecx, edx);
/* Run BMI2 test only if host has BMI2 support. */