2012-04-25 Sriraman Tallam <tmsriram@google.com>
authortmsriram <tmsriram@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Apr 2012 00:52:09 +0000 (00:52 +0000)
committertmsriram <tmsriram@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 26 Apr 2012 00:52:09 +0000 (00:52 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186855 138bc75d-0d04-0410-961f-82ee72b054a4

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 22011ca..ef6fc51 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 13cb4bd..a34c68c 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 7c0d2f2..473339e 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 92c1160..a566f6a 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 0258cd2..7705315 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 831fa12..16fb553 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 dccf1d5..6934778 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