# setvl: Set Vector Length
+<!-- hide -->
See links:
* <http://lists.libre-soc.org/pipermail/libre-soc-dev/2020-November/001366.html>
* <https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#vsetvlivsetvl-instructions>
* [[sv/svstep]]
* pseudocode [[openpower/isa/simplev]]
+<!-- show -->
Add the following section to the Simple-V Chapter
this is compensated for in the assembly notation. i.e. that an immediate
value of 1 in assembler notation actually places the value 0b0000000 in
the `SVi` field bits: on execution the `setvl` instruction adds one to
-the decoded `SVi` field bits, resulting in VL/MVL being set to 1. This
-allows VL to be set to values ranging from 1 to 128 with only 7 bits
+the decoded `SVi` field bits, resulting in VL/MVL being set to 1. In future
+this will allow VL to be set to values ranging from 1 to 128 with only 7 bits
instead of 8. Setting VL/MVL to 0 would result in all Vector operations
becoming `nop`. If this is truly desired (nop behaviour) then setting
VL and MVL to zero is to be done via the [[SVSTATE SPR|sv/sprs]].
The reasoning here is that the opportunity to set RT equal to the
immediate `SVi+1` is sacrificed in favour of setting from CTR.
-## Unusual Rc=1 behaviour
+**Unusual Rc=1 behaviour**
Normally, the return result from an instruction is in `RT`. With it
being possible for `RT=0` to mean that `CTR` mode is to be read, some
### Loop using Rc=1
In this example, the `setvl.` instruction enabled Rc=1, which
-sets CR0.eq when VL becomes zero.
+sets CR0.eq when VL becomes zero. Testing of `r4` (cmpi) is thus redundant
+saving one instruction.
```
my_fn:
FP register required to be loaded. The block of memory from which the
registers are loaded is contiguous (no gaps): any FP register which has
a corresponding zero bit in `r3` is *unaltered*. In essence this is a
-selective LD-multi with "Scatter" capability.
+selective LD-multi with "Scatter" (`VCOMPRESS`) capability.
```
setvli r0, MVL=64, VL=64
sv.fld/dm=r3 *r0, 0(r30) # selective load 64 FP registers
```
-Up to 64 FPRs will be saved, here. Again, `r3`
+Up to 64 FPRs will be saved, here. Again, `r3` specifies which
+registers are set in a `VEXPAND` fashion.
```
setvli r0, MVL=64, VL=64