summaryrefslogtreecommitdiff
path: root/neozip/arch/loongarch/slide_hash_lasx.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_lasx.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_lasx.c')
-rw-r--r--neozip/arch/loongarch/slide_hash_lasx.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/neozip/arch/loongarch/slide_hash_lasx.c b/neozip/arch/loongarch/slide_hash_lasx.c
new file mode 100644
index 0000000000..f464779090
--- /dev/null
+++ b/neozip/arch/loongarch/slide_hash_lasx.c
@@ -0,0 +1,49 @@
+/*
+ * LASX optimized hash slide, based on Intel AVX2 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>
+ * Mika T. Lindqvist <postmaster@raasu.org>
+ *
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifdef LOONGARCH_LASX
+
+#include "zbuild.h"
+#include "deflate.h"
+
+#include <lasxintrin.h>
+
+static inline void slide_hash_chain(Pos *table, uint32_t entries, const __m256i wsize) {
+ table += entries;
+ table -= 32;
+
+ do {
+ __m256i value1, value2, result1, result2;
+
+ value1 = __lasx_xvld(table, 0);
+ value2 = __lasx_xvld(table, 32);
+ result1 = __lasx_xvssub_hu(value1, wsize);
+ result2 = __lasx_xvssub_hu(value2, wsize);
+ __lasx_xvst(result1, table, 0);
+ __lasx_xvst(result2, table, 32);
+
+ table -= 32;
+ entries -= 32;
+ } while (entries > 0);
+}
+
+Z_INTERNAL void slide_hash_lasx(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 __m256i ymm_wsize = __lasx_xvreplgr2vr_h((short)wsize);
+
+ slide_hash_chain(s->head, HASH_SIZE, ymm_wsize);
+ slide_hash_chain(s->prev, wsize, ymm_wsize);
+}
+
+#endif