]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR driver/50740 (CPUID leaf 7 for BMI/BMI2/AVX2 feature detection not qualified...
authorH.J. Lu <hongjiu.lu@intel.com>
Fri, 21 Oct 2011 14:32:32 +0000 (16:32 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Fri, 21 Oct 2011 14:32:32 +0000 (16:32 +0200)
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

gcc/ChangeLog
gcc/config/i386/driver-i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avx2-check.h
gcc/testsuite/gcc.target/i386/bmi2-check.h

index 16da4d66a0f3039407ad9b29de57e1515d2f738f..86658cb2a95bac908c0d6b7aaafcc54fb3d04a8f 100644 (file)
@@ -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.
 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.
 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>
index 8107ecee7c96ac821199cca8646bca0747066479..5f14c76fe55e1d10554b99618a0e6bfccd9f5526 100644 (file)
@@ -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)
index a1b2752c45f4872abd5783aaf56ae5b30eb0f377..ef3404611df70772ca2d8defb2174d56a950cd96 100644 (file)
@@ -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
index 22c9b39da45862c87553962249ecdc1b5983c4ce..424335dbb5eadefd7b10a6f9788b4c5591c7a428 100644 (file)
@@ -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))
index 5ffce44fc6eddb8ee3f2de916704c951024b0497..c933a49f28171ac973ae8e70e561493d4285a12b 100644 (file)
@@ -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.  */