qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] target/riscv: Fix the element agnostic function problem


From: Richard Henderson
Subject: Re: [PATCH v2] target/riscv: Fix the element agnostic function problem
Date: Wed, 20 Mar 2024 22:18:04 -1000
User-agent: Mozilla Thunderbird

On 3/20/24 17:58, Huang Tao wrote:
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 <eric.huang@linux.alibaba.com>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
---
Changes in v2:
- Keep the api of vext_set_elems_1s
- Reduce the number of patches.
---
  target/riscv/vector_internals.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)

diff --git a/target/riscv/vector_internals.c b/target/riscv/vector_internals.c
index 12f5964fbb..3e45b9b4a7 100644
--- a/target/riscv/vector_internals.c
+++ b/target/riscv/vector_internals.c
@@ -30,6 +30,28 @@ void vext_set_elems_1s(void *base, uint32_t is_agnostic, 
uint32_t cnt,
      if (tot - cnt == 0) {
          return ;
      }
+
+#if HOST_BIG_ENDIAN
+    /*
+     * Deal the situation when the elements are insdie
+     * only one uint64 block including setting the
+     * masked-off element.
+     */
+    if ((tot - 1) ^ cnt < 8) {
+        memset(base + H1(tot - 1), -1, tot - cnt);
+        return;
+    }

(1) tot will always be a multiple of 8, afaik, so there's no need for this 
first block.
(2) Using if not #if means that the code is always compile-tested, even if it 
is eliminated.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]