Skip to content

Optimize swizzle_dyn for LoongArch64 with N is 16 or 32#533

Merged
calebzulawski merged 1 commit into
rust-lang:masterfrom
heiher:swizzle-dyn-loong64
Jun 23, 2026
Merged

Optimize swizzle_dyn for LoongArch64 with N is 16 or 32#533
calebzulawski merged 1 commit into
rust-lang:masterfrom
heiher:swizzle-dyn-loong64

Conversation

@heiher

@heiher heiher commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

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.

Comment thread crates/core_simd/src/swizzle_dyn.rs Outdated
Comment thread crates/core_simd/src/swizzle_dyn.rs Outdated
@heiher heiher force-pushed the swizzle-dyn-loong64 branch from 9ef2797 to 30bdfe3 Compare June 22, 2026 13:58
@programmerjake

Copy link
Copy Markdown
Member

I've run all swizzle_dyn::lanes_* tests locally, and they all passed.

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.

@heiher

heiher commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

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.

Yeah. I tested it locally with:

RUSTFLAGS="-C target-feature=+lasx" cargo test -r

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

@calebzulawski calebzulawski merged commit 44a03e6 into rust-lang:master Jun 23, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants