selftests: riscv: check all elements in vector register init test
PATCH 1/1 selftests: riscv: check all elements in vector register init test
From: Zongmin Zhou <[email protected]>
The register scrubbing test attempts to read each element with vmv.x.s and advance to the next element with vsrl.vi reg, reg, 8. However, vsrl.vi shifts each element independently and never moves the next element into element 0. With SEW=8, the immediate 8 is also truncated to 0, making the instruction a no-op. The loop therefore re-reads element 0 vl times, and leftover data in any other element goes unnoticed.
Replace the shift with vslidedown.vi reg, reg, 1, which actually moves the elements down by one. The instruction has the same encoding in RVV 1.0 and the T-Head vector extension 0.7.1, so it is safe to use on both code paths of the test.
--- tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/testing/selftests/riscv/vector/v_exec_initval_nolibc.c +2 -1
@@ -40,7 +40,8 @@ int main(int argc, char **argv)".option push\n\t" \".option arch, +v\n\t" \ "vmv.x.s %0, " __stringify(register) "\n\t" \ - "vsrl.vi " __stringify(register) ", " __stringify(register) ", 8\n\t" \ + "vslidedown.vi " __stringify(register) ", " \ + __stringify(register) ", 1\n\t" \ ".option pop\n\t" \ : "=r" (value)); \if (value != 0x00) { \
Signature · 5 lines
2.34.1 No virus found Checked by Hillstone Network AntiVirus