]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add compatibility header for VX instructions
authorNathan Moein Vaziri <nathan@nathanm.com>
Thu, 2 Apr 2026 01:08:26 +0000 (18:08 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 10 Apr 2026 11:38:03 +0000 (13:38 +0200)
GCC/Clang don't support vec_sub or vec_subs, but IBM compiler does.

arch/s390/crc32_vx.c
arch/s390/slide_hash_vx.c
arch/s390/vx_intrins.h [new file with mode: 0644]
cmake/detect-intrinsics.cmake
configure

index 18ebacedb659c6179c845d9dbd8d4db48d4e363a..b8383db1f130b9696a0d32b2f5a0fd5b11ad4d43 100644 (file)
@@ -17,7 +17,7 @@
 #include "zbuild.h"
 #include "arch_functions.h"
 
-#include <vecintrin.h>
+#include "vx_intrins.h"
 
 typedef unsigned char uv16qi __attribute__((vector_size(16)));
 typedef unsigned int uv4si __attribute__((vector_size(16)));
index aa308fda234a8893c636a94b749f0da4a9ab17aa..03f722e9922700577f775f9056bb184842e8bc61 100644 (file)
@@ -7,7 +7,7 @@
 #include "zbuild.h"
 #include "deflate.h"
 
-#include <vecintrin.h>
+#include "vx_intrins.h"
 
 static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize) {
     const vector unsigned short vmx_wsize = vec_splats(wsize);
diff --git a/arch/s390/vx_intrins.h b/arch/s390/vx_intrins.h
new file mode 100644 (file)
index 0000000..ad82d98
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef S390_VX_INTRINS_H
+#define S390_VX_INTRINS_H
+
+#include <vecintrin.h>
+
+#ifndef vec_sub
+#define vec_sub(a, b) ((a) - (b))
+#endif
+#ifndef vec_subs
+static inline uv8hi vec_subs_u16(uv8hi a, uv8hi b) {
+    return a - vec_min(a, b);
+}
+#define vec_subs(a, b) vec_subs_u16((a), (b))
+#endif
+
+#endif
index 7615c16d860039f9f39c04c902c4c80f2bb2654a..bc68c04f5fc6b37d86029398d372c01766dfed8d 100644 (file)
@@ -694,7 +694,7 @@ macro(check_s390_vx_intrinsics)
         int main(void) {
             unsigned char a __attribute__((vector_size(16))) = { 0 };
             unsigned char b __attribute__((vector_size(16))) = { 0 };
-            a = vec_sub(a, b);
+            a = vec_min(a, b);
             a = vec_xl(0, (unsigned char *)0);
             return a[0];
         }"
index cc6802ce708bd46e6da9365fbd89f16fce56c1fb..bb7156e545ee95544841f5f1e0b89e804fb20974 100755 (executable)
--- a/configure
+++ b/configure
@@ -1725,7 +1725,7 @@ check_s390_vx_intrinsics() {
 int main(void) {
     unsigned char a __attribute__((vector_size(16))) = { 0 };
     unsigned char b __attribute__((vector_size(16))) = { 0 };
-    a = vec_sub(a, b);
+    a = vec_min(a, b);
     a = vec_xl(0, (unsigned char *)0);
     return a[0];
 }