Repository navigation
arm/neon: add LSX implementations for vpaddlq_{s8,s16,u8,u16} - #1456
Merged
Merged
Conversation
These had no LSX path, so the 128-bit pairwise-add-long fell back to lo = vshrq_n_u16(vshlq_n_u16(vreinterpretq_u16_u8(a), 8), 8); hi = vshrq_n_u16(vreinterpretq_u16_u8(a), 8); return vaddq_u16(lo, hi); four vector operations for what is a single instruction on LSX: vhaddw_<wide>_<narrow> adds adjacent elements pairwise across all sixteen bytes of both operands, so passing the same register twice yields exactly the eight pairwise sums. This matters for libjpeg-turbo's h2v1/h2v2 downsampling, which is built on vpadalq_u8 (= vaddq_u16(a, vpaddlq_u8(b))). Measured on Loongson 3A5000HV with libjpeg-turbo built -DWITH_SIMDE=1 -DWITH_PROFILE=1 -O2, per-pass throughput from tjbench: -subsamp 422 downsampling 3850 -> 4320 Msamples/sec (+12.2%) -subsamp 420 downsampling 4963 -> 6822 Msamples/sec (+37.5%) and the kernel itself shrinks from 60 to 52 (h2v1) and 76 to 64 (h2v2) instructions.
mr-c
approved these changes
Oct 9, 2026
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.
These had no LSX path, so the 128-bit pairwise-add-long fell back to
lo = vshrq_n_u16(vshlq_n_u16(vreinterpretq_u16_u8(a), 8), 8);
hi = vshrq_n_u16(vreinterpretq_u16_u8(a), 8);
return vaddq_u16(lo, hi);
four vector operations for what is a single instruction on LSX: vhaddw__ adds adjacent elements pairwise across all sixteen bytes of both operands, so passing the same register twice yields exactly the eight pairwise sums.
This matters for libjpeg-turbo's h2v1/h2v2 downsampling, which is built on vpadalq_u8 (= vaddq_u16(a, vpaddlq_u8(b))). Measured on Loongson 3A5000HV with libjpeg-turbo built -DWITH_SIMDE=1 -DWITH_PROFILE=1 -O2, per-pass throughput from tjbench:
-subsamp 422 downsampling 3850 -> 4320 Msamples/sec (+12.2%)
-subsamp 420 downsampling 4963 -> 6822 Msamples/sec (+37.5%)
and the kernel itself shrinks from 60 to 52 (h2v1) and 76 to 64 (h2v2) instructions.