Skip to content

tcg/riscv64: Fix vector immediate handling

Philippe Mathieu-Daudé qemu-arm qemu-devel qemu-riscv 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 Latest6 patches 20 repliesIn review

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6tcg/riscv64: Factor encode_vi_raw() out of encode_vi()tcg/riscv64/tcg-target.c.inc+8 -22 replies
2/6tcg/riscv64: Use a uimm5 encoder for vector shift immediatestcg/riscv64/tcg-target.c.inc+16 -12 replies
3/6tcg/riscv64: Extract elements for vector arithmetic immediatestcg/riscv64/tcg-target.c.inc+17 -63 replies
4/6tcg/riscv64: Fix constant handling in vector comparisons and selectstcg/riscv64/tcg-target.c.inc+7 -63 replies
5/6tcg/riscv64: Fix logical vector immediate matching and emissiontcg/riscv64/tcg-target-con-set.h tcg/riscv64/tcg-target-con-str.h tcg/riscv64/tcg-target.c.inc+48 -75 replies
6/6tests/tcg/aarch64: Add vector immediate regression teststests/tcg/aarch64/meson.build tests/tcg/aarch64/sve-vec-imm.c+234 -01 reply

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchRichard HendersonAurelien Jarno
1/6R-b R-b
2/6R-b R-b
3/6R-b
4/6R-b
5/6R-b R-b
6/6A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/6] tcg/riscv64: Fix vector immediate handling

The riscv64 backend mishandles constant operands of RVV .vi forms:

- logical ops apply the immediate at a stale SEW (wrong results, since v9.2);
- arithmetic, compare and select ops encode the whole replicated 64-bit constant instead of one element;
- shifts take uimm5, but the encoder checks for simm5.

1-2: add a uimm5 encoder for shifts,
3-4: extract one element (vec_imm()) for arithmetic and compare/select, 5: follow rth suggestion of adding a new constraint to pick the smallest
element size at which the constant replicates as a simm5, and the emitter switches SEW to it,
6: AI-generated regression test.

Tested with qemu-aarch64 built for a riscv64 host (debug-TCG), run under qemu-riscv64 -cpu max: the new test fails or aborts before the series, and passes with it at every SVE vector length.

[1] https://lore.kernel.org/qemu-devel/[email protected]/
Supersedes: <[email protected]>

Philippe Mathieu-Daudé (6):
tcg/riscv64: Factor encode_vi_raw() out of encode_vi() tcg/riscv64: Use a uimm5 encoder for vector shift immediates tcg/riscv64: Extract elements for vector arithmetic immediates tcg/riscv64: Fix constant handling in vector comparisons and selects tcg/riscv64: Fix logical vector immediate matching and emission tests/tcg/aarch64: Add vector immediate regression tests

 tcg/riscv64/tcg-target-con-set.h |   1 +
 tcg/riscv64/tcg-target-con-str.h |   1 +
 tests/tcg/aarch64/sve-vec-imm.c  | 233 +++++++++++++++++++++++++++++++
 tcg/riscv64/tcg-target.c.inc     | 116 ++++++++++++---
 tests/tcg/aarch64/meson.build    |   1 +
 5 files changed, 330 insertions(+), 22 deletions(-)
 create mode 100644 tests/tcg/aarch64/sve-vec-imm.c
Signature · 1 line
2.55.0