riscv-software-src / riscv-isa-sim

Spike, a RISC-V ISA Simulator
Other
2.44k stars 857 forks source link

Clarification on VMSEQ Instruction Behavior (riscv vector spec1.0) #1808

Open latifbhatti opened 1 month ago

latifbhatti commented 1 month ago

I am working with the vmseq.vv instruction and would like to confirm if my understanding is correct. Here's the scenario:

Vectors:
v10 = (10, 20, 32, 12)
v15 = (10, 36, 11, 12)
v30 = (62, 99, 68, 61)

Applying the instruction:
vmseq.vv v30, v10, v15

According to the vmseq instruction, the comparison produces a mask (1001) indicating that the first and last elements of v10 and v15 are equal. Based on this mask, the updated values of v30 should be:

v30 = (10, 99, 68, 12)

Could you please confirm if this result is correct?

aswaterman commented 1 month ago

The four LSBs of v30 will be set to 1001. The remaining bits are treated as tail-agnostic. So assuming those numbers are hexadecimal representations of byte elements, you might end up with something like

(69, 99, 68, 61) (i.e. only the first nibble of the first element was modified)

or

(f9, ff, ff, ff) (i.e. the tail-agnostic policy set all of the remaining bits to 1).

Spike uses the first policy.