[PATCH, i386]: PR 66954, function multiversioning for target "pclmul"

Uros Bizjak ubizjak@gmail.com
Tue Aug 11 17:57:00 GMT 2015


This patch adds multiversioning for target "pclmul", after similar
patch has been committed for multiversioning for taget "aes".

libgcc/ChangeLog:

2015-08-11  Uros Bizjak  <ubizjak@gmail.com>

    PR target/66954
    * config/i386/cpuinfo.c (enum processor_features): Add FEATURE_PCLMUL.
    (get_available_features): Handle FEATURE_PCLMUL.

gcc/ChangeLog:

2015-08-11  Uros Bizjak  <ubizjak@gmail.com>

    PR target/66954
    * config/i386/i386.c (get_builtin_code_for_version): Add P_PCLMUL
    to enum feature_priority and feature_list.
    (fold_builtin_cpu): Add F_PCLMUL to enum processor_features
    and isa_names_table.

gcc/testsuite/ChangeLog:

2015-08-11  Uros Bizjak  <ubizjak@gmail.com>

    PR target/66954
    * g++.dg/ext/mv25.C: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
-------------- next part --------------
Index: libgcc/config/i386/cpuinfo.c
===================================================================
--- libgcc/config/i386/cpuinfo.c	(revision 226773)
+++ libgcc/config/i386/cpuinfo.c	(working copy)
@@ -101,7 +101,8 @@ enum processor_features
   FEATURE_AVX512F,
   FEATURE_BMI,
   FEATURE_BMI2,
-  FEATURE_AES
+  FEATURE_AES,
+  FEATURE_PCLMUL
 };
 
 struct __processor_model
@@ -277,6 +278,8 @@ get_available_features (unsigned int ecx, unsigned
     features |= (1 << FEATURE_POPCNT);
   if (ecx & bit_AES)
     features |= (1 << FEATURE_AES);
+  if (ecx & bit_PCLMUL)
+    features |= (1 << FEATURE_PCLMUL);
   if (ecx & bit_SSE3)
     features |= (1 << FEATURE_SSE3);
   if (ecx & bit_SSSE3)
Index: gcc/testsuite/g++.dg/ext/mv25.C
===================================================================
--- gcc/testsuite/g++.dg/ext/mv25.C	(revision 0)
+++ gcc/testsuite/g++.dg/ext/mv25.C	(revision 0)
@@ -0,0 +1,35 @@
+// Test case to check if Multiversioning works for PCLMUL
+
+// { dg-do run { target i?86-*-* x86_64-*-* } }
+// { dg-require-ifunc "" }
+// { dg-options "-O2" }
+
+#include <assert.h>
+
+// Check if PCLMUL feature selection works
+int foo () __attribute__((target("default")));
+int foo () __attribute__((target("pclmul")));
+
+int main ()
+{
+  int val = foo ();
+
+  if (__builtin_cpu_supports ("pclmul"))
+    assert (val == 1);
+  else
+    assert (val == 0);
+
+  return 0;
+}
+
+int __attribute__ ((target("default")))
+foo ()
+{
+  return 0;
+}
+
+int __attribute__ ((target("pclmul")))
+foo ()
+{
+  return 1;
+}
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 226773)
+++ gcc/config/i386/i386.c	(working copy)
@@ -34574,6 +34574,7 @@ get_builtin_code_for_version (tree decl, tree *pre
     P_PROC_SSE4_2,
     P_POPCNT,
     P_AES,
+    P_PCLMUL,
     P_AVX,
     P_PROC_AVX,
     P_BMI,
@@ -34612,6 +34613,7 @@ get_builtin_code_for_version (tree decl, tree *pre
       {"sse4.2", P_SSE4_2},
       {"popcnt", P_POPCNT},
       {"aes", P_AES},
+      {"pclmul", P_PCLMUL},
       {"avx", P_AVX},
       {"bmi", P_BMI},
       {"fma4", P_FMA4},
@@ -35600,6 +35602,7 @@ fold_builtin_cpu (tree fndecl, tree *args)
     F_BMI,
     F_BMI2,
     F_AES,
+    F_PCLMUL,
     F_MAX
   };
 
@@ -35696,7 +35699,8 @@ fold_builtin_cpu (tree fndecl, tree *args)
       {"avx512f",F_AVX512F},
       {"bmi",    F_BMI},
       {"bmi2",   F_BMI2},
-      {"aes",    F_AES}
+      {"aes",    F_AES},
+      {"pclmul", F_PCLMUL}
     };
 
   tree __processor_model_type = build_processor_model_struct ();


More information about the Gcc-patches mailing list