Skip to content

Commit ca7271f

Browse files
committed
feature: we added the '-msse4.2' and '-march' CC options to always dynamically enable the CRC32 string hashing optimization.
1 parent 07c120e commit ca7271f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

README.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,8 @@ local newstate = jit.prngstate(123456)
163163
**syntax:** *ok = jit.crc32()*
164164

165165
Returns a boolean value indicating if the current architecture supports a CRC32
166-
instruction set.
167-
168-
CRC32 support will be checked at runtime if LuaJIT was compiled with `-msse4.2`
169-
on x64 architectures, or `-march=armv8-a+crc` on ARM64.
166+
instruction set. CRC32 support will be checked at runtime on x64 and ARM64
167+
platforms.
170168

171169
CRC32 support allows for this branch to use an optimized string hashing
172170
algorithm. See the [String hashing](#string-hashing) section for details on
@@ -285,10 +283,8 @@ but makes hash collision attacks harder for strings up to 127 bytes of size
285283
(see `lj_str_new()`).
286284

287285
This optimization is only available for x64 and ARM64 architectures, and will
288-
be enabled if:
289-
290-
1. LuaJIT is compiled with `-msse4.2` on x64, or `-march=armv8-a+crc` on ARM64.
291-
2. A CRC32 instruction set is detected at runtime (see [jit.crc32](#jitcrc32)).
286+
be enabled if a CRC32 instruction set is detected at runtime (see
287+
[jit.crc32](#jitcrc32)).
292288

293289
**Note:** This optimization can be disabled by compiling LuaJIT with
294290
`-DLJ_OR_DISABLE_STRHASHCRC32`.

src/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ CCOPT= -O2 -fomit-frame-pointer
4747
# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
4848
# the binaries to a different machine you could also use: -march=native
4949
#
50-
CCOPT_x86= -march=i686 -msse -msse2 -mfpmath=sse
50+
CCOPT_x86= -march=i686 -msse -msse2 -msse4.2 -mfpmath=sse
5151
CCOPT_x64=
5252
CCOPT_arm=
53-
CCOPT_arm64=
53+
CCOPT_arm64= -march=armv8-a+crc
5454
CCOPT_ppc=
5555
CCOPT_mips=
5656
#

0 commit comments

Comments
 (0)