Skip to content

Commit b498067

Browse files
committed
Fix AVX2 support for Windows builds with MSC
It was never detected, so the existing code for AVX2 was compiled but never used. Signed-off-by: Stefan Weil <[email protected]>
1 parent fc55b58 commit b498067

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/arch/simddetect.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,24 @@ SIMDDetect::SIMDDetect() {
107107
}
108108
# elif defined(_WIN32)
109109
int cpuInfo[4];
110+
int max_function_id;
110111
__cpuid(cpuInfo, 0);
111-
if (cpuInfo[0] >= 1) {
112+
max_function_id = cpuInfo[0];
113+
if (max_function_id >= 1) {
112114
__cpuid(cpuInfo, 1);
113115
#if defined(SSE4_1)
114116
sse_available_ = (cpuInfo[2] & 0x00080000) != 0;
115117
#endif
116118
#if defined(AVX)
117119
avx_available_ = (cpuInfo[2] & 0x10000000) != 0;
120+
#endif
121+
#if defined(AVX2)
122+
if (max_function_id >= 7) {
123+
__cpuid(cpuInfo, 7);
124+
avx2_available_ = (cpuInfo[1] & 0x00000020) != 0;
125+
avx512F_available_ = (cpuInfo[1] & 0x00010000) != 0;
126+
avx512BW_available_ = (cpuInfo[1] & 0x40000000) != 0;
127+
}
118128
#endif
119129
}
120130
#else

0 commit comments

Comments
 (0)