Skip to content

Add Zvzip extension#2529

Open
ved-rivos wants to merge 1 commit into
riscv:mainfrom
ved-rivos:zvzip
Open

Add Zvzip extension#2529
ved-rivos wants to merge 1 commit into
riscv:mainfrom
ved-rivos:zvzip

Conversation

@ved-rivos
Copy link
Copy Markdown
Collaborator

@ved-rivos ved-rivos commented Dec 21, 2025

Zvzip standard extension provides instructions for reordering structured data in vector registers. These instruction address usages such as packing and unpacking data structures such as color components of a pixel, real and imaginary components of complex numbers, transposing small matrices, among others.

@ved-rivos ved-rivos added the Ratification Pending At Ratification-Ready, pending approval. label Dec 21, 2025
@ved-rivos ved-rivos changed the title Add unratified Zvzip extension Add Zvzip extension Dec 21, 2025
@aswaterman
Copy link
Copy Markdown
Member

Thanks! As usual, we'll leave this open until ratification.

Comment thread src/zvzip.adoc Outdated
@ved-rivos ved-rivos force-pushed the zvzip branch 2 times, most recently from d836874 to 736ba6b Compare December 29, 2025 15:12
@nadime15
Copy link
Copy Markdown
Contributor

nadime15 commented Jan 6, 2026

Is it intentional that this chapter is not included in the compilation flow? Since it’s not embedded anywhere (e.g., in /src/riscv-unprivileged.adoc), it won’t appear in the final artifacts.

@ved-rivos ved-rivos force-pushed the zvzip branch 2 times, most recently from 24cc987 to 6b9871d Compare January 18, 2026 22:19
@ved-rivos
Copy link
Copy Markdown
Collaborator Author

Is it intentional that this chapter is not included in the compilation flow? Since it’s not embedded anywhere (e.g., in /src/riscv-unprivileged.adoc), it won’t appear in the final artifacts.

I have included it in the build but it may not be the best place to include the chapter.

@ved-rivos ved-rivos force-pushed the zvzip branch 2 times, most recently from 815df8d to 307777c Compare January 18, 2026 23:10
Comment thread src/zvzip.adoc Outdated
Comment thread src/zvzip.adoc Outdated
@ved-rivos ved-rivos force-pushed the zvzip branch 2 times, most recently from 602d498 to 6e5ee5b Compare January 20, 2026 23:12
Copy link
Copy Markdown
Contributor

@nibrunie nibrunie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it seems all those instructions support optional masking, there are very few information about the masking behavior (in particular which index of mask should be used for each result element in vzip.vv). I am wondering if it could be integrated in the pseudo code or described somewhat.

Comment thread src/zvzip.adoc
@ved-rivos
Copy link
Copy Markdown
Collaborator Author

ved-rivos commented Jan 28, 2026

Although it seems all those instructions support optional masking, there are very few information about the masking behavior (in particular which index of mask should be used for each result element in vzip.vv). I am wondering if it could be integrated in the pseudo code or described somewhat.

@nibrunie The pseudocode is updated to include the masking behavior. Please take a look.

@nibrunieAtSi5
Copy link
Copy Markdown
Contributor

Although it seems all those instructions support optional masking, there are very few information about the masking behavior (in particular which index of mask should be used for each result element in vzip.vv). I am wondering if it could be integrated in the pseudo code or described somewhat.

@nibrunie The pseudocode is updated to include the masking behavior. Please take a look.

Looks good to me, thank you for making the changes @ved-rivos.

@ved-rivos ved-rivos force-pushed the zvzip branch 4 times, most recently from fe26866 to 7f1dfac Compare January 29, 2026 00:21
@ved-rivos ved-rivos force-pushed the zvzip branch 4 times, most recently from 8212d32 to 3a2672e Compare January 29, 2026 16:06
Comment thread src/zvzip.adoc Outdated
Comment thread src/zvzip.adoc Outdated
@nadime15
Copy link
Copy Markdown
Contributor

nadime15 commented Feb 2, 2026

@ved-rivos I guess the extension depends on Zve32x, right? If so, I think this should be mentioned.

@ved-rivos
Copy link
Copy Markdown
Collaborator Author

I guess the extension depends on Zve32x, right? If so, I think this should be mentioned.

The extension depends on the V Extension for Application Processors or the Zve32x Extension for Embedded Processors. I will mention it.

@nadime15
Copy link
Copy Markdown
Contributor

nadime15 commented Feb 2, 2026

Zve32x is a subset of V, so mentioning Zve32x should be enough.

@nibrunieAtSi5
Copy link
Copy Markdown
Contributor

nibrunieAtSi5 commented Feb 2, 2026

Zve32x is a subset of V, so mentioning Zve32x should be enough.

Agreed with @nadime15 , V implies Zve32x, so mentioning Zve32x should be enough (Zve64x could be added to extend to SEW=64 case).
No mention of v should be required IMHO (we have done that in the past for other extensions and I think it was a mistake).

@camel-cdr
Copy link
Copy Markdown

Would it be appropriate to add notes to each instruction for how they can be implemented by software in base RVV?

Because I suspect people will search the spec for things like "zip" or "transpose", when needing those things in code, and there are relatively efficient patterns for all of them (much better than vrgather), which are non-trivial to come up with:

vzip.vv vd, vs1, vs2 -> vwaddu.vv vd, vs1, vs2; vwmaccu.vx vd, -1, vs2

vunzipe.v vd, vs1 -> vnsrl.vx vd, vs1, 0
vunzipo.v vd, vs1 -> vnsrl.vx vd, vs1, \SEW/8

vpaire.v vd, vs1, vd -> vslide1up.vx   vd, vs1, 0, vm=odd-bits
vpairo.v vd, vs1, vd -> vslide1down.vx vd, vs1, 0, vm=even-bits

@nibrunieAtSi5
Copy link
Copy Markdown
Contributor

Would it be appropriate to add notes to each instruction for how they can be implemented by software in base RVV?

Because I suspect people will search the spec for things like "zip" or "transpose", when needing those things in code, and there are relatively efficient patterns for all of them (much better than vrgather), which are non-trivial to come up with:

vzip.vv vd, vs1, vs2 -> vwaddu.vv vd, vs1, vs2; vwmaccu.vx vd, -1, vs2

vunzipe.v vd, vs1 -> vnsrl.vx vd, vs1, 0
vunzipo.v vd, vs1 -> vnsrl.vx vd, vs1, \SEW/8

vpaire.v vd, vs1, vd -> vslide1up.vx   vd, vs1, 0, vm=odd-bits
vpairo.v vd, vs1, vd -> vslide1down.vx vd, vs1, 0, vm=even-bits

Does the first pattern work for any SEW (including ELEN) ?

@camel-cdr
Copy link
Copy Markdown

The unzip/zip pattern doesn't work for SEW=ELEN

@Xu-Dsus4
Copy link
Copy Markdown

Hi all, I would like to clarify whether there should be a constraint of "if masked, cannot overlap the mask register" for all instructions in the zvzip extension. Currently, the specification only mentions that this check needs to be performed for vpairo/vpaire. Thanks.

@aswaterman
Copy link
Copy Markdown
Member

aswaterman commented Apr 14, 2026

@Xu-Dsus4 All vector instructions have a standard set of overlap rules, unless otherwise relaxed. Those rules include the one you mention. The spec authors can comment, but my guess is that the vpairo/vpaire mask-overlap rules are redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ratification Pending At Ratification-Ready, pending approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants