]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Remove unneeded code at preproc stage
authorMatthew Barr <matthew.barr@intel.com>
Thu, 29 Oct 2015 23:43:43 +0000 (10:43 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 30 Oct 2015 00:28:38 +0000 (11:28 +1100)
If we know we have BMI2 we shouldn't produce the fallback code.

src/util/bitutils.h
src/util/shuffle.h

index 6fdafa71dcbd354f9527462c6f64cfca642b2a30..979a2c045b3c348c42298155cf222613224ecdef 100644 (file)
@@ -254,7 +254,7 @@ u32 compress32(u32 x, u32 m) {
 #if defined(__BMI2__)
     // BMI2 has a single instruction for this operation.
     return _pext_u32(x, m);
-#endif
+#else
 
     // Return zero quickly on trivial cases
     if ((x & m) == 0) {
@@ -281,6 +281,7 @@ u32 compress32(u32 x, u32 m) {
     }
 
     return x;
+#endif
 }
 
 static really_inline
@@ -288,7 +289,7 @@ u64a compress64(u64a x, u64a m) {
 #if defined(ARCH_X86_64) && defined(__BMI2__)
     // BMI2 has a single instruction for this operation.
     return _pext_u64(x, m);
-#endif
+#else
 
     // Return zero quickly on trivial cases
     if ((x & m) == 0) {
@@ -316,6 +317,7 @@ u64a compress64(u64a x, u64a m) {
     }
 
     return x;
+#endif
 }
 
 static really_inline
@@ -323,7 +325,7 @@ u32 expand32(u32 x, u32 m) {
 #if defined(__BMI2__)
     // BMI2 has a single instruction for this operation.
     return _pdep_u32(x, m);
-#endif
+#else
 
     // Return zero quickly on trivial cases
     if (!x || !m) {
@@ -355,6 +357,7 @@ u32 expand32(u32 x, u32 m) {
     }
 
     return x & m0; // clear out extraneous bits
+#endif
 }
 
 static really_inline
@@ -362,7 +365,7 @@ u64a expand64(u64a x, u64a m) {
 #if defined(ARCH_X86_64) && defined(__BMI2__)
     // BMI2 has a single instruction for this operation.
     return _pdep_u64(x, m);
-#endif
+#else
 
     // Return zero quickly on trivial cases
     if (!x || !m) {
@@ -395,6 +398,7 @@ u64a expand64(u64a x, u64a m) {
     }
 
     return x & m0; // clear out extraneous bits
+#endif
 }
 
 
index 847d07a03ec0a43335843bea16b018b23acfdb43..ba85fb5deb0cd91cd5d26e6bda2328515a99134f 100644 (file)
@@ -51,7 +51,7 @@ u32 shuffleDynamic32(u32 x, u32 mask) {
 #if defined(HAVE_PEXT)
     // Intel BMI2 can do this operation in one instruction.
     return _pext_u32(x, mask);
-#endif
+#else
 
     u32 result = 0, num = 1;
     while (mask != 0) {
@@ -63,6 +63,7 @@ u32 shuffleDynamic32(u32 x, u32 mask) {
         num <<= 1;
     }
     return result;
+#endif
 }
 
 static really_inline
@@ -70,7 +71,7 @@ u32 shuffleDynamic64(u64a x, u64a mask) {
 #if defined(HAVE_PEXT) && defined(ARCH_64_BIT)
     // Intel BMI2 can do this operation in one instruction.
     return _pext_u64(x, mask);
-#endif
+#else
 
     u32 result = 0, num = 1;
     while (mask != 0) {
@@ -82,6 +83,7 @@ u32 shuffleDynamic64(u64a x, u64a mask) {
         num <<= 1;
     }
     return result;
+#endif
 }
 
 #undef HAVE_PEXT