riscv / riscv-v-spec

Working draft of the proposed RISC-V V vector extension
https://jira.riscv.org/browse/RVG-122
Creative Commons Attribution 4.0 International
958 stars 272 forks source link

New vector instructions suggestion: vrotateup and vrotatedown #672

Open tony-cole opened 3 years ago

tony-cole commented 3 years ago

In addition to the slide1down instruction in issue #671 and the existing slideup/down instructions:

vslideup.vx
vslideup.vi

vslidedown.vx
vslidedown.vi

It would be useful to have rotation as well, e.g.:

vrotateup.vx
vrotateup.vi

vrotatedown.vx
vrotatedown.vi

where they operate as follows:

vrotateup.vx vd, vs2, rs1, vm       # vd[(i+rs1) % vl] = vs2[i]
vrotateup.vi vd, vs2, uimm[4:0], vm # vd[(i+uimm) % vl] = vs2[i]

vrotatedown.vx vd, vs2, rs1, vm       # vd[i] = vs2[(i+rs1) % vl]
vrotatedown.vi vd, vs2, uimm[4:0], vm # vd[i] = vs2[(i+uimm) % vl]

I know I can use a vrgather.vv instruction to do this, but that needs setting up which wastes (a lot of) CPU time and a grouped vector register.

tony-cole commented 3 years ago

I've have a way to do this with Tail Undisturbed and a few instructions, see: https://github.com/riscv/riscv-v-spec/issues/664#issuecomment-836810691

Although a dedicated instruction would be faster.