riscv: optimize FindMatchLengthWithLimit and memmove16 with RVV#1489
Closed
Felix-Gong wants to merge 1 commit into
Closed
riscv: optimize FindMatchLengthWithLimit and memmove16 with RVV#1489Felix-Gong wants to merge 1 commit into
Felix-Gong wants to merge 1 commit into
Conversation
Add RISC-V Vector Extension (RVV) 1.0 optimizations for two hot paths: 1. FindMatchLengthWithLimit (compression path): - Uses RVV vector comparison to process up to 16 bytes per iteration - vle8.v loads, vmsne.vv compares, vfirst.m finds first mismatch - Up to 25% compression speedup at Q11 on text data 2. memmove16 (decompression path): - Uses RVV vector load/store for 16-byte copy - Symmetric with existing NEON optimization - ~5% decompression speedup on large files Both optimizations are gated behind BROTLI_RVV_1 macro, auto-detected from __riscv_v >= 1.0.0. Falls back to scalar code on non-RVV targets. Tested: 28 roundtrip tests + 22 compatibility tests all pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add RISC-V Vector Extension (RVV) 1.0 optimizations for two hot paths in brotli.
1. FindMatchLengthWithLimit (compression path, c/enc/find_match_length.h)
Uses RVV vector comparison to process up to 16 bytes per iteration:
Falls back to original scalar code for remaining bytes via vsetvl dynamic length.
2. memmove16 (decompression path, c/dec/decode.c)
Uses RVV vector load/store for 16-byte copy, symmetric with existing NEON optimization.
3. Platform detection (c/common/platform.h)
Auto-detects RVV 1.0+ from compiler predefined macros. No manual configuration needed.
Performance
Tested on RISC-V 64-bit server with GCC 15.1.0, -O2 -march=rv64gcv.
Q11 compression (best of 3 runs, brotli official testdata):
Notes
Supersedes #1410. Zero impact on non-RISC-V targets.