Skip to content

Commit af1e2cd

Browse files
Huang TaoMichael Tokarev
authored andcommitted
target/riscv: Fix the element agnostic function problem
In RVV and vcrypto instructions, the masked and tail elements are set to 1s using vext_set_elems_1s function if the vma/vta bit is set. It is the element agnostic policy. However, this function can't deal the big endian situation. This patch fixes the problem by adding handling of such case. Signed-off-by: Huang Tao <[email protected]> Suggested-by: Richard Henderson <[email protected]> Reviewed-by: LIU Zhiwei <[email protected]> Cc: qemu-stable <[email protected]> Message-ID: <[email protected]> Signed-off-by: Alistair Francis <[email protected]> (cherry picked from commit 75115d8) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 2dcc48b commit af1e2cd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

target/riscv/vector_internals.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,28 @@ void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt,
3030
if (tot - cnt == 0) {
3131
return ;
3232
}
33+
34+
if (HOST_BIG_ENDIAN) {
35+
/*
36+
* Deal the situation when the elements are insdie
37+
* only one uint64 block including setting the
38+
* masked-off element.
39+
*/
40+
if (((tot - 1) ^ cnt) < 8) {
41+
memset(base + H1(tot - 1), -1, tot - cnt);
42+
return;
43+
}
44+
/*
45+
* Otherwise, at least cross two uint64_t blocks.
46+
* Set first unaligned block.
47+
*/
48+
if (cnt % 8 != 0) {
49+
uint32_t j = ROUND_UP(cnt, 8);
50+
memset(base + H1(j - 1), -1, j - cnt);
51+
cnt = j;
52+
}
53+
/* Set other 64bit aligend blocks */
54+
}
3355
memset(base + cnt, -1, tot - cnt);
3456
}
3557

0 commit comments

Comments
 (0)