slide_hash_armv6.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* slide_hash_armv6.c -- Optimized hash table shifting for ARMv6 with support for SIMD instructions
  2. * Copyright (C) 2023 Cameron Cawley
  3. * For conditions of distribution and use, see copyright notice in zlib.h
  4. */
  5. #if defined(ARM_SIMD)
  6. #include "acle_intrins.h"
  7. #include "zbuild.h"
  8. #include "deflate.h"
  9. /* SIMD version of hash_chain rebase */
  10. static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize) {
  11. Z_REGISTER uint16x2_t v;
  12. uint16x2_t p0, p1, p2, p3;
  13. Z_REGISTER size_t n;
  14. size_t size = entries*sizeof(table[0]);
  15. Assert((size % (sizeof(uint16x2_t) * 4) == 0), "hash table size err");
  16. Assert(sizeof(Pos) == 2, "Wrong Pos size");
  17. v = wsize | (wsize << 16);
  18. n = size / (sizeof(uint16x2_t) * 4);
  19. do {
  20. p0 = *((const uint16x2_t *)(table));
  21. p1 = *((const uint16x2_t *)(table+2));
  22. p2 = *((const uint16x2_t *)(table+4));
  23. p3 = *((const uint16x2_t *)(table+6));
  24. p0 = __uqsub16(p0, v);
  25. p1 = __uqsub16(p1, v);
  26. p2 = __uqsub16(p2, v);
  27. p3 = __uqsub16(p3, v);
  28. *((uint16x2_t *)(table)) = p0;
  29. *((uint16x2_t *)(table+2)) = p1;
  30. *((uint16x2_t *)(table+4)) = p2;
  31. *((uint16x2_t *)(table+6)) = p3;
  32. table += 8;
  33. } while (--n);
  34. }
  35. Z_INTERNAL void slide_hash_armv6(deflate_state *s) {
  36. unsigned int wsize = s->w_size;
  37. slide_hash_chain(s->head, HASH_SIZE, wsize);
  38. slide_hash_chain(s->prev, wsize, wsize);
  39. }
  40. #endif