How does VIOTA.M handle masking?
With vm=0, v0 selects active elements; with vm=1, all body elements participate. Inactive and tail elements follow the current policies.
Count set bits in the source mask before each element and write the prefix count to integer vector vd.
VIOTA.M is a RISC-V V mask prefix-count instruction. For each active element i, it counts set elements in source mask vs2 with index less than i and writes the count to vd. It is commonly used for compaction, scatter indexing, or deriving compact indices from a mask.
VIOTA.M outputs how many matching bits appear before each position; it does not include the current bit itself.
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vmseq.vi v0, v8, 0 viota.m v12, v0 # v12[i]=count of zeros before i».
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vmseq.vi v0, v8, 0 viota.m v12, v0 # v12[i]=count of zeros before i».
Understand this scenario with real code like «vsetvli t0, a0, e32, m1, ta, ma vmseq.vi v0, v8, 0 viota.m v12, v0 # v12[i]=count of zeros before i».
With vm=0, v0 selects active elements; with vm=1, all body elements participate. Inactive and tail elements follow the current policies.