From e8ac138c83a39e3dd869e1cfed593f6207cfbe61 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Sun, 7 Aug 2022 15:20:43 +0800 Subject: [PATCH] util: Improve has_sse has_sse2 has_sse3 has_sse4_1 has_avx disable handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the prepare for following changes: * Handling GALLIUM_NOSSE in u_cpu_detect.c * Handling LP_FORCE_SSE2 and LP_NATIVE_VECTOR_WIDTH in u_cpu_detect.c Signed-off-by: Yonggang Luo Reviewed-by: Jose Fonseca Part-of: --- src/util/u_cpu_detect.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/util/u_cpu_detect.c b/src/util/u_cpu_detect.c index 9e13d5ac61a..9e6ac9d0a59 100644 --- a/src/util/u_cpu_detect.c +++ b/src/util/u_cpu_detect.c @@ -793,13 +793,39 @@ util_cpu_detect_once(void) if (cacheline > 0) util_cpu_caps.cacheline = cacheline; } + } +#endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */ - if (!util_cpu_caps.has_sse) { - util_cpu_caps.has_sse2 = 0; - util_cpu_caps.has_sse3 = 0; - util_cpu_caps.has_ssse3 = 0; - util_cpu_caps.has_sse4_1 = 0; - } +#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) + if (!util_cpu_caps.has_sse) { + util_cpu_caps.has_sse2 = 0; + } + if (!util_cpu_caps.has_sse2) { + util_cpu_caps.has_sse3 = 0; + } + if (!util_cpu_caps.has_sse3) { + util_cpu_caps.has_ssse3 = 0; + util_cpu_caps.has_sse4_1 = 0; + } + if (!util_cpu_caps.has_sse4_1) { + util_cpu_caps.has_sse4_2 = 0; + util_cpu_caps.has_avx = 0; + } + if (!util_cpu_caps.has_avx) { + util_cpu_caps.has_avx2 = 0; + util_cpu_caps.has_f16c = 0; + util_cpu_caps.has_fma = 0; + + /* avx512 are cleared */ + util_cpu_caps.has_avx512f = 0; + util_cpu_caps.has_avx512dq = 0; + util_cpu_caps.has_avx512ifma = 0; + util_cpu_caps.has_avx512pf = 0; + util_cpu_caps.has_avx512er = 0; + util_cpu_caps.has_avx512cd = 0; + util_cpu_caps.has_avx512bw = 0; + util_cpu_caps.has_avx512vl = 0; + util_cpu_caps.has_avx512vbmi = 0; } #endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */