Specialise constant-mask swizzle for lsx and lasx - #1422
Merged
serge-sans-paille merged 1 commit intoOct 2, 2026
Merged
Conversation
serge-sans-paille
requested changes
Oct 2, 2026
On lsx the only new case is the identity mask, which returns the batch unchanged. Every other mask takes the runtime path as before. On lasx there are four cases. An identity mask again returns the batch unchanged. The other three exist because xvshuf.b only shuffles within each 128 bit lane, so permuting bytes across the whole register is the expensive case and worth avoiding. When no element crosses a lane, a single xvshuf.b does the whole job, once each index is reduced to an offset within its own lane. When every element reads from a single lane, that lane is first broadcast to both lanes with xvpermi.q, after which the same single xvshuf.b applies. Any other mask takes the runtime path as before. Those three cases apply only where the element type is one byte. Wider element types get the identity check and nothing else.
domibel
force-pushed
the
lsx-swizzle-const-mask
branch
from
October 2, 2026 18:22
c68530d to
440d2f5
Compare
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.
On lsx the only new case is the identity mask, which returns the batch unchanged. Every other mask takes the runtime path as before.
On lasx there are four. An identity mask again returns the batch unchanged. The other three exist because xvshuf.b only shuffles within each 128 bit half of the register, so permuting bytes across the whole register is the expensive case and worth avoiding. When no element reads from the other half, a single xvshuf.b does the whole job, with each index taken modulo the half width so that it addresses its own half. When every element reads from the low half, that half is first broadcast to both halves with xvpermi.q 0x00, after which the same single xvshuf.b applies; a mask reading only the high half is the same with 0x11. Any other mask takes the runtime path as before.
Those three cases apply only where the element type is one byte. Wider element types get the identity check and nothing else.