Skip to content

Commit 9fbed33

Browse files
authored
Merge pull request #4251 from facebook/x32_bmi2
BMI2 detection in 32-bit mode
2 parents e475dc4 + a556559 commit 9fbed33

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ The file structure is designed to make this selection manually achievable for an
149149
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
150150
the shared library, which is now hidden by default.
151151

152+
- The build macro `STATIC_BMI2` can be set to 1 to force usage of `bmi2` instructions.
153+
It is generally not necessary to set this build macro,
154+
because `STATIC_BMI2` will be automatically set to 1
155+
on detecting the presence of the corresponding instruction set in the compilation target.
156+
It's nonetheless available as an optional manual toggle for better control,
157+
and can also be used to forcefully disable `bmi2` instructions by setting it to 0.
158+
152159
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
153160
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
154161
These instructions contribute to better performance, notably on the decoder side.

lib/common/compiler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@
209209

210210
/* Like DYNAMIC_BMI2 but for compile time determination of BMI2 support */
211211
#ifndef STATIC_BMI2
212-
# if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_I86))
212+
# if defined(_MSC_VER)
213213
# ifdef __AVX2__ /* MSVC does not have a BMI2 specific flag, but every CPU that supports AVX2 also supports BMI2 */
214214
# define STATIC_BMI2 1
215215
# endif
216-
# elif defined(__BMI2__) && defined(__x86_64__) && defined(__GNUC__)
216+
# elif defined(__BMI2__)
217217
# define STATIC_BMI2 1
218218
# endif
219219
#endif

0 commit comments

Comments
 (0)