summaryrefslogtreecommitdiff
path: root/neozip/arch/loongarch/slide_hash_lsx.c
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 19:56:09 +0300
commit7fb132859fda54aa96bc9dd46d302b343eeb5a02 (patch)
treeb43ae77d7451fb470a260c03349a1caf2846c5e5 /neozip/arch/loongarch/slide_hash_lsx.c
parentb1e34e861b5d732afe828d58aad2c638135061fd (diff)
parentc2712b8a345191f6ed79558c089777df94590087 (diff)
downloadProject-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.tar.gz
Project-Tick-7fb132859fda54aa96bc9dd46d302b343eeb5a02.zip
Add 'neozip/' from commit 'c2712b8a345191f6ed79558c089777df94590087'
git-subtree-dir: neozip git-subtree-mainline: b1e34e861b5d732afe828d58aad2c638135061fd git-subtree-split: c2712b8a345191f6ed79558c089777df94590087
Diffstat (limited to 'neozip/arch/loongarch/slide_hash_lsx.c')
-rw-r--r--neozip/arch/loongarch/slide_hash_lsx.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/neozip/arch/loongarch/slide_hash_lsx.c b/neozip/arch/loongarch/slide_hash_lsx.c
new file mode 100644
index 0000000000..f4c94ea70d
--- /dev/null
+++ b/neozip/arch/loongarch/slide_hash_lsx.c
@@ -0,0 +1,54 @@
+/*
+ * LSX optimized hash slide, based on Intel SSE implementation
+ *
+ * Copyright (C) 2017 Intel Corporation
+ * Copyright (C) 2025 Vladislav Shchapov <vladislav@shchapov.ru>
+ * Authors:
+ * Arjan van de Ven <arjan@linux.intel.com>
+ * Jim Kukunas <james.t.kukunas@linux.intel.com>
+ *
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifdef LOONGARCH_LSX
+
+#include "zbuild.h"
+#include "deflate.h"
+
+#include <lsxintrin.h>
+#include <assert.h>
+
+static inline void slide_hash_chain(Pos *table, uint32_t entries, const __m128i wsize) {
+ table += entries;
+ table -= 16;
+
+ /* ZALLOC allocates this pointer unless the user chose a custom allocator.
+ * Our alloc function is aligned to 64 byte boundaries */
+ do {
+ __m128i value0, value1, result0, result1;
+
+ value0 = __lsx_vld(table, 0);
+ value1 = __lsx_vld(table, 16);
+ result0 = __lsx_vssub_hu(value0, wsize);
+ result1 = __lsx_vssub_hu(value1, wsize);
+ __lsx_vst(result0, table, 0);
+ __lsx_vst(result1, table, 16);
+
+ table -= 16;
+ entries -= 16;
+ } while (entries > 0);
+}
+
+Z_INTERNAL void slide_hash_lsx(deflate_state *s) {
+ Assert(s->w_size <= UINT16_MAX, "w_size should fit in uint16_t");
+ uint16_t wsize = (uint16_t)s->w_size;
+ const __m128i xmm_wsize = __lsx_vreplgr2vr_h((short)wsize);
+
+ assert(((uintptr_t)s->head & 15) == 0);
+ assert(((uintptr_t)s->prev & 15) == 0);
+
+ slide_hash_chain(s->head, HASH_SIZE, xmm_wsize);
+ slide_hash_chain(s->prev, wsize, xmm_wsize);
+}
+
+#endif