]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
no longer limit automated BMI2 detection to x64 4251/head
authorYann Collet <yann.collet.73@gmail.com>
Sun, 19 Jan 2025 08:08:57 +0000 (00:08 -0800)
committerYann Collet <yann.collet.73@gmail.com>
Sun, 19 Jan 2025 08:08:57 +0000 (00:08 -0800)
this was previously no triggered in x86 32-bit mode,
due to a limitation in `bitstream.h`, that was fixed in #4248.

Now, `bmi2` will be automatically detected and triggered
at compilation time, if the corresponding instruction set is enabled,
even in 32-bit mode.

Also: updated library documentation, to feature STATIC_BMI2 build variable

lib/README.md
lib/common/compiler.h

index 0f6c6474550105de6cc886821c3b0c0e07727cbb..b37f5fc4f3ffeaae05b5b157f44f92a5c4adfe82 100644 (file)
@@ -149,6 +149,13 @@ The file structure is designed to make this selection manually achievable for an
   will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
   the shared library, which is now hidden by default.
 
+- The build macro `STATIC_BMI2` can be set to 1 to force usage of `bmi2` instructions.
+  It is generally not necessary to set this build macro,
+  because `STATIC_BMI2` will be automatically set to 1
+  on detecting the presence of the corresponding instruction set in the compilation target.
+  It's nonetheless available as an optional manual toggle for better control,
+  and can also be used to forcefully disable `bmi2` instructions by setting it to 0.
+
 - The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
   which can detect at runtime the presence of BMI2 instructions, and use them only if present.
   These instructions contribute to better performance, notably on the decoder side.
index 7927c4fb648c21c32655b9aabdc62071b1727a24..6fd2d08e7317384d5dd29d32b262aeece5f0e33e 100644 (file)
 
 /* Like DYNAMIC_BMI2 but for compile time determination of BMI2 support */
 #ifndef STATIC_BMI2
-#  if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))
+#  if defined(_MSC_VER)
 #    ifdef __AVX2__  /* MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2 */
 #       define STATIC_BMI2 1
 #    endif
-#  elif defined(__BMI2__) && defined(__x86_64__) && defined(__GNUC__)
+#  elif defined(__BMI2__)
 #    define STATIC_BMI2 1
 #  endif
 #endif