aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-04-16 14:52:15 +0200
committerAnton Khirnov <anton@khirnov.net>2024-04-16 16:31:30 +0200
commitbf320a3d0f5c526f0d96551681c37e20b3f44efb (patch)
tree9e6b725c583ff4ccd306066291b4c57042ba8a66
parentc6361b600df58ad1c20c6e45384f408543dcf5c2 (diff)
cpu: add AVX512 support
-rw-r--r--cpu.c2
-rw-r--r--cpu.h1
-rw-r--r--util.asm4
3 files changed, 6 insertions, 1 deletions
diff --git a/cpu.c b/cpu.c
index 3dd2ae8..a7b7231 100644
--- a/cpu.c
+++ b/cpu.c
@@ -76,6 +76,8 @@ static int get_cpu_flags_x86(void)
if (ebx & 0x00000100)
rval |= MG2DI_CPU_FLAG_BMI2;
}
+ if ((ebx & 0xD0030000) == 0xD0030000)
+ rval |= MG2DI_CPU_FLAG_AVX512;
}
mg2di_cpu_cpuid(0x80000000, &max_ext_level, &ebx, &ecx, &edx);
diff --git a/cpu.h b/cpu.h
index e0c501d..a757003 100644
--- a/cpu.h
+++ b/cpu.h
@@ -43,6 +43,7 @@
#define MG2DI_CPU_FLAG_FMA3 0x10000 ///< Haswell FMA3 functions
#define MG2DI_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1
#define MG2DI_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2
+#define MG2DI_CPU_FLAG_AVX512 (1<<16)
int mg2di_cpu_flags_get(void);
diff --git a/util.asm b/util.asm
index 846ea3b..864080f 100644
--- a/util.asm
+++ b/util.asm
@@ -29,7 +29,9 @@
%error Invalid selector %3
%endif
- %if mmsize == 32 && cpuflag(avx2)
+ %if mmsize == 64 && cpuflag(avx512)
+ vbroadcastsd %1, %2
+ %elif mmsize == 32 && cpuflag(avx2)
vpermpd %1, %2, _IMM8SPLAT2B(%3)
%elif mmsize == 32 && cpuflag(avx)
shufpd %1, %2, %2, _IMM4SPLAT1B(%3 & 1)