slide_hash_rvv.c 934 B

1234567891011121314151617181920212223242526272829303132
  1. /* slide_hash_rvv.c - RVV version of slide_hash
  2. * Copyright (C) 2023 SiFive, Inc. All rights reserved.
  3. * Contributed by Alex Chiang <alex.chiang@sifive.com>
  4. * For conditions of distribution and use, see copyright notice in zlib.h
  5. */
  6. #ifdef RISCV_RVV
  7. #include <riscv_vector.h>
  8. #include "zbuild.h"
  9. #include "deflate.h"
  10. static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize) {
  11. size_t vl;
  12. while (entries > 0) {
  13. vl = __riscv_vsetvl_e16m4(entries);
  14. vuint16m4_t v_tab = __riscv_vle16_v_u16m4(table, vl);
  15. vuint16m4_t v_diff = __riscv_vssubu_vx_u16m4(v_tab, wsize, vl);
  16. __riscv_vse16_v_u16m4(table, v_diff, vl);
  17. table += vl, entries -= vl;
  18. }
  19. }
  20. Z_INTERNAL void slide_hash_rvv(deflate_state *s) {
  21. uint16_t wsize = (uint16_t)s->w_size;
  22. slide_hash_chain(s->head, HASH_SIZE, wsize);
  23. slide_hash_chain(s->prev, wsize, wsize);
  24. }
  25. #endif // RISCV_RVV