Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zlib: add riscv64 simd optimization #855

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ else()
CMAKE_C_COMPILER_TARGET MATCHES "^aarch64-.*"))
set(OS_AARCH64 TRUE)
endif()
if (CMAKE_C_COMPILER_TARGET MATCHES "^riscv64-.*")
set(OS_RISCV64 TRUE)
endif()
# Fix MINGW (native mingw)'s CMAKE_SYSTEM_PROCESSOR
if (MINGW)
if (OS_X86)
Expand Down
13 changes: 12 additions & 1 deletion third_party/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ if ((OS_ARM AND ANDROID) OR OS_AARCH64)
set(ZLIB_USE_ARM_NEON TRUE)
endif()

if (OS_RISCV64)
message(STATUS "zlib: use riscv64 rvv optimization")
set(ZLIB_USE_RISCV64_OPTIMIZATIONS TRUE)
endif()

if (ZLIB_USE_X86_X64_OPTIMIZATIONS)
# zlib_adler32_simd
target_compile_definitions(zlib PUBLIC "ADLER32_SIMD_SSSE3")
Expand Down Expand Up @@ -151,7 +156,13 @@ elseif(ZLIB_USE_ARM_NEON)
crc32_simd.c
crc32_simd.h
)
elseif (ZLIB_USE_RISCV64_OPTIMIZATIONS)
target_compile_definitions(zlib PUBLIC "RISCV_RVV")
target_compile_definitions(zlib PUBLIC "DEFLATE_SLIDE_HASH_RVV")
target_compile_definitions(zlib PUBLIC "ADLER32_SIMD_RVV")
target_compile_options(zlib PRIVATE "-march=rv64gcv")
target_sources(zlib PRIVATE inflate.c)
else()
target_compile_definitions(zlib PUBLIC "-DCPU_NO_SIMD")
target_compile_definitions(zlib PUBLIC "CPU_NO_SIMD")
target_sources(zlib PRIVATE inflate.c)
endif()
Loading