From ef29dc4af7c7d5fc5dbfc9766fcd128ce0e48687 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 3 Jul 2023 20:20:25 -0400 Subject: [PATCH] MT#56471 add detection for SSE2 Not used at this point Change-Id: I027a33ba89fb9be8c201ce1109570eb156464ea5 --- lib/codeclib.c | 8 ++++++-- lib/codeclib.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/codeclib.c b/lib/codeclib.c index 8bbef8435..fb327a593 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -1182,18 +1182,22 @@ bool rtpe_has_cpu_flag(enum rtpe_cpu_flag flag) { if (!done) { #if defined(__x86_64__) - int32_t ebx_7h0h; + int32_t ebx_7h0h, edx_1h; __asm ( + "mov $1, %%eax" "\n\t" + "cpuid" "\n\t" + "mov %%edx, %1" "\n\t" "mov $7, %%eax" "\n\t" "xor %%ecx, %%ecx" "\n\t" "cpuid" "\n\t" "mov %%ebx, %0" "\n\t" - : "=rm" (ebx_7h0h) + : "=rm" (ebx_7h0h), "=rm" (edx_1h) : : "eax", "ebx", "ecx", "edx" ); + cpu_flags[RTPE_CPU_FLAG_SSE2] = !!(edx_1h & (1L << 26)); cpu_flags[RTPE_CPU_FLAG_AVX2] = !!(ebx_7h0h & (1L << 5)); cpu_flags[RTPE_CPU_FLAG_AVX512BW] = !!(ebx_7h0h & (1L << 30)); cpu_flags[RTPE_CPU_FLAG_AVX512F] = !!(ebx_7h0h & (1L << 16)); diff --git a/lib/codeclib.h b/lib/codeclib.h index 3eab0046b..4d6fb523a 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -65,6 +65,7 @@ enum rtpe_cpu_flag { RTPE_CPU_FLAG_AVX2 = 0, RTPE_CPU_FLAG_AVX512BW, RTPE_CPU_FLAG_AVX512F, + RTPE_CPU_FLAG_SSE2, __NUM_RTPE_CPU_FLAGS };