Skip to content

Add Zvzip extension#2529

Open
Ved Shanbhogue (ved-rivos) wants to merge 1 commit into
riscv:mainfrom
ved-rivos:zvzip
Open

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

Conversation

@ved-rivos

@ved-rivos Ved Shanbhogue (ved-rivos) commented Dec 21, 2025

Copy link
Copy Markdown
Collaborator

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.

@aswaterman

Copy link
Copy Markdown
Member

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

Comment thread src/zvzip.adoc Outdated
@nadime15

Copy link
Copy Markdown
Contributor

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

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.

Comment thread src/zvzip.adoc Outdated
Comment thread src/zvzip.adoc Outdated

@nibrunie Nicolas Brunie (nibrunie) left a comment

Copy link
Copy Markdown
Contributor

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

Ved Shanbhogue (ved-rivos) commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator Author

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.

Nicolas Brunie (@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.

Nicolas Brunie (@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 Shanbhogue (@ved-rivos).

Comment thread src/zvzip.adoc Outdated
Comment thread src/zvzip.adoc Outdated
@nadime15

Copy link
Copy Markdown
Contributor

Ved Shanbhogue (@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

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

@nibrunieAtSi5

Nicolas Brunie (nibrunieAtSi5) commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

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

Agreed with Nadime Barhoumi (@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

Andrew Waterman (aswaterman) commented Apr 14, 2026

Copy link
Copy Markdown
Member

Xu Shicheng (@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