0008-target-riscv-fix-vrgather-macro-index-variable-type-.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 9c254f0ff496098e3fbc2bad0cca89b031467280 Mon Sep 17 00:00:00 2001
  2. From: Frank Chang <frank.chang@sifive.com>
  3. Date: Fri, 16 Apr 2021 17:34:56 +0800
  4. Subject: [PATCH 008/107] target/riscv: fix vrgather macro index variable type
  5. bug
  6. ETYPE may be type of uint64_t, thus index variable has to be declared as
  7. type of uint64_t, too. Otherwise the value read from vs1 register may be
  8. truncated to type of uint32_t.
  9. Signed-off-by: Frank Chang <frank.chang@sifive.com>
  10. ---
  11. target/riscv/vector_helper.c | 6 ++++--
  12. 1 file changed, 4 insertions(+), 2 deletions(-)
  13. diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
  14. index 356cef8a09..4651a1e224 100644
  15. --- a/target/riscv/vector_helper.c
  16. +++ b/target/riscv/vector_helper.c
  17. @@ -4796,7 +4796,8 @@ void HELPER(NAME)(void *vd, void *v0, void *vs1, void *vs2, \
  18. uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \
  19. uint32_t vm = vext_vm(desc); \
  20. uint32_t vl = env->vl; \
  21. - uint32_t index, i; \
  22. + uint64_t index; \
  23. + uint32_t i; \
  24. \
  25. for (i = 0; i < vl; i++) { \
  26. if (!vm && !vext_elem_mask(v0, mlen, i)) { \
  27. @@ -4826,7 +4827,8 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1, void *vs2, \
  28. uint32_t vlmax = env_archcpu(env)->cfg.vlen / mlen; \
  29. uint32_t vm = vext_vm(desc); \
  30. uint32_t vl = env->vl; \
  31. - uint32_t index = s1, i; \
  32. + uint64_t index = s1; \
  33. + uint32_t i; \
  34. \
  35. for (i = 0; i < vl; i++) { \
  36. if (!vm && !vext_elem_mask(v0, mlen, i)) { \
  37. --
  38. 2.33.1