Optimize swizzle_dyn for LoongArch64 with N is 16 or 32#533
Merged
Conversation
9ef2797 to
30bdfe3
Compare
Member
do you have LASX? afaik it isn't tested unless you enable it as a target feature when building portable-simd, since afaict CI doesn't enable it. |
Contributor
Author
Yeah. I tested it locally with:
000000000005ae80 <_RNvNtNtCs1775If9jsmw_9core_simd9core_simd11swizzle_dyn19loong64_lsx_swizzle>:
5ae80: 2c0000a0 vld $vr0, $a1, 0
5ae84: 2c0000c1 vld $vr1, $a2, 0
5ae88: 0d508000 vshuf.b $vr0, $vr0, $vr0, $vr1
5ae8c: 72843c21 vslei.bu $vr1, $vr1, 0xf
5ae90: 71260400 vand.v $vr0, $vr0, $vr1
5ae94: 2c400080 vst $vr0, $a0, 0
5ae98: 4c000020 ret
000000000005aea0 <_RNvNtNtCs1775If9jsmw_9core_simd9core_simd11swizzle_dyn20loong64_lasx_swizzle>:
5aea0: 2c8000a0 xvld $xr0, $a1, 0
5aea4: 2c8000c1 xvld $xr1, $a2, 0
5aea8: 77d40002 xvori.b $xr2, $xr0, 0x0
5aeac: 77ec0002 xvpermi.q $xr2, $xr0, 0x0
5aeb0: 77ec4400 xvpermi.q $xr0, $xr0, 0x11
5aeb4: 0d608800 xvshuf.b $xr0, $xr0, $xr2, $xr1
5aeb8: 76847c21 xvslei.bu $xr1, $xr1, 0x1f
5aebc: 75260400 xvand.v $xr0, $xr0, $xr1
5aec0: 2cc00080 xvst $xr0, $a0, 0
5aec4: 4c000020 ret |
programmerjake
approved these changes
Jun 23, 2026
This was referenced Jun 23, 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.
We can optimize swizzles for 16-byte and 32-byte vectors using LoongArch LSX/LASX shuffle instructions.
For reference, see the Unofficial LoongArch Intrinsics Guide:
https://jia.je/unofficial-loongarch-intrinsics-guide
I've run all
swizzle_dyn::lanes_*tests locally, and they all passed.