i386-cpuinfo.c (FEATURE_AVX2): New enum value.
authorSriraman Tallam <tmsriram@google.com>
Thu, 26 Apr 2012 00:52:09 +0000 (00:52 +0000)
committerSriraman Tallam <tmsriram@gcc.gnu.org>
Thu, 26 Apr 2012 00:52:09 +0000 (00:52 +0000)
2012-04-25  Sriraman Tallam  <tmsriram@google.com>

* config/i386/i386-cpuinfo.c (FEATURE_AVX2): New enum value.
(get_available_features): New argument. Check for AVX2.
(__cpu_indicator_init): Modify call to get_available_features.

* doc/extend.texi: Document avx2 support.
* config/i386/i386.c (fold_builtin_cpu): Add avx2.

* testsuite/gcc.target/i386/builtin_target.c: Check avx2.

From-SVN: r186855

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/builtin_target.c
libgcc/ChangeLog
libgcc/config/i386/i386-cpuinfo.c

index 22011ca9e6c89df8f192ff32887f9b26bcda8ebb..ef6fc511086f319d78a6cdd6db3d63888b33cd45 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-25  Sriraman Tallam  <tmsriram@google.com>
+
+       * doc/extend.texi: Document avx2 support.
+       * config/i386/i386.c (fold_builtin_cpu): Add avx2.
+
 2012-04-26  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/53120
index 13cb4bd60343c32d7955adf8ea98c84b7638b13b..a34c68c418e7e69628cb54a39b91a60876cd8da1 100644 (file)
@@ -27763,6 +27763,7 @@ fold_builtin_cpu (tree fndecl, tree *args)
     F_SSE4_1,
     F_SSE4_2,
     F_AVX,
+    F_AVX2,
     F_MAX
   };
 
@@ -27830,7 +27831,8 @@ fold_builtin_cpu (tree fndecl, tree *args)
       {"ssse3",  F_SSSE3},
       {"sse4.1", F_SSE4_1},
       {"sse4.2", F_SSE4_2},
-      {"avx",    F_AVX}
+      {"avx",    F_AVX},
+      {"avx2",   F_AVX2}
     };
 
   static tree __processor_model_type = NULL_TREE;
index 7c0d2f23b6bff4f8cf0e951e37bbf0efd18076ba..473339ec736c15daa57b3a5a88d972af874d96c5 100644 (file)
@@ -9541,6 +9541,8 @@ SSE4.1 instructions.
 SSE4.2 instructions.
 @item avx
 AVX instructions.
+@item avx2
+AVX2 instructions.
 @end table
 
 Here is an example:
index 92c11605aaa4ab6063f4a8bb2106574d8f8a22e1..a566f6a7e1bbe3816e89396ea748b1e14dc4d497 100644 (file)
@@ -1,3 +1,7 @@
+2012-04-25  Sriraman Tallam  <tmsriram@google.com>
+
+       * testsuite/gcc.target/i386/builtin_target.c: Check avx2.
+
 2012-04-26  Alan Modra  <amodra@gmail.com>
 
        * gcc.target/powerpc/savres.c: New test.
index 0258cd246d22caff9960baf88d575f4fb5d31033..770531585ecec4f375f8034ed1c48afe2bc3593a 100644 (file)
@@ -29,6 +29,8 @@ fn1 ()
 
   assert (__builtin_cpu_supports ("avx") >= 0);
 
+  assert (__builtin_cpu_supports ("avx2") >= 0);
+
   /* Check CPU type.  */
   assert (__builtin_cpu_is ("amd") >= 0);
 
index 831fa12203a22819163bc9f2943dbd661358f3e7..16fb55318c167e0f2159c97e56eae9299b6d4df8 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-25  Sriraman Tallam  <tmsriram@google.com>
+
+       * config/i386/i386-cpuinfo.c (FEATURE_AVX2): New enum value.
+       (get_available_features): New argument. Check for AVX2.
+       (__cpu_indicator_init): Modify call to get_available_features.
+
 2012-04-25  Alan Modra  <amodra@gmail.com>
 
        * config/rs6000/crtsavevr.S: New file.
index dccf1d58f27d6b2e01b240659640b56219b899df..6934778c0fcff6b11d48718a731a6163fdf1383c 100644 (file)
@@ -75,7 +75,8 @@ enum processor_features
   FEATURE_SSSE3,
   FEATURE_SSE4_1,
   FEATURE_SSE4_2,
-  FEATURE_AVX
+  FEATURE_AVX,
+  FEATURE_AVX2
 };
 
 struct __processor_model
@@ -191,8 +192,11 @@ get_intel_cpu (unsigned int family, unsigned int model, unsigned int brand_id)
     }
 }                      
 
+/* ECX and EDX are output of CPUID at level one.  MAX_CPUID_LEVEL is
+   the max possible level of CPUID insn.  */
 static void
-get_available_features (unsigned int ecx, unsigned int edx)
+get_available_features (unsigned int ecx, unsigned int edx,
+                       int max_cpuid_level)
 {
   unsigned int features = 0;
 
@@ -217,6 +221,15 @@ get_available_features (unsigned int ecx, unsigned int edx)
   if (ecx & bit_AVX)
     features |= (1 << FEATURE_AVX);
 
+  /* Get Advanced Features at level 7 (eax = 7, ecx = 0). */
+  if (max_cpuid_level >= 7)
+    {
+      unsigned int eax, ebx, ecx, edx;
+      __cpuid_count (7, 0, eax, ebx, ecx, edx);
+      if (ebx & bit_AVX2)
+       features |= (1 << FEATURE_AVX2);
+    }
+
   __cpu_model.__cpu_features[0] = features;
 }
 
@@ -296,7 +309,7 @@ __cpu_indicator_init (void)
       /* Get CPU type.  */
       get_intel_cpu (family, model, brand_id);
       /* Find available features. */
-      get_available_features (ecx, edx);
+      get_available_features (ecx, edx, max_level);
       __cpu_model.__cpu_vendor = VENDOR_INTEL;
     }
   else if (vendor == SIG_AMD)
@@ -311,7 +324,7 @@ __cpu_indicator_init (void)
       /* Get CPU type.  */
       get_amd_cpu (family, model);
       /* Find available features. */
-      get_available_features (ecx, edx);
+      get_available_features (ecx, edx, max_level);
       __cpu_model.__cpu_vendor = VENDOR_AMD;
     }
   else