From eae338e0e6f3d6948f47bfc015d95fa7e9553d00 Mon Sep 17 00:00:00 2001 From: Julian Calaby Date: Mon, 27 Jun 2016 22:41:13 +1000 Subject: [PATCH] libFLAC/cpu.c: Move cpu_id_ex into cpu_info_x86() This simplifies the C code without complexifying the preprocessor code. --- src/libFLAC/cpu.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/libFLAC/cpu.c b/src/libFLAC/cpu.c index 592aee73..25a7f444 100644 --- a/src/libFLAC/cpu.c +++ b/src/libFLAC/cpu.c @@ -436,21 +436,6 @@ void FLAC__cpu_info (FLAC__CPUInfo *info) #if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN -#if defined _MSC_VER || defined __INTEL_COMPILER -static inline void -cpu_id_ex (int *cpuinfo, int result) -{ -// Stupid MSVC doesn't know how to optimise out: -// if (FLAC_AVC_SUPPORTER) -// __cpuidex(cpuinfo, level, 0); /* for AVX2 detection */ -#if FLAC__AVX_SUPPORTED - __cpuidex(cpuinfo, result, 0); /* for AVX2 detection */ -#else - __cpuid(cpuinfo, result); /* some old compilers don't support __cpuidex */ -#endif -} -#endif - void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx, FLAC__uint32 *ecx, FLAC__uint32 *edx) { #if defined _MSC_VER || defined __INTEL_COMPILER @@ -458,7 +443,11 @@ void FLAC__cpu_info_x86(FLAC__uint32 level, FLAC__uint32 *eax, FLAC__uint32 *ebx int ext = level & 0x80000000; __cpuid(cpuinfo, ext); if((unsigned)cpuinfo[0] >= level) { - cpu_id_ex (cpuinfo, ext); +#if FLAC__AVX_SUPPORTED + __cpuidex(cpuinfo, ext, 0); /* for AVX2 detection */ +#else + __cpuid(cpuinfo, ext); /* some old compilers don't support __cpuidex */ +#endif *eax = cpuinfo[0]; *ebx = cpuinfo[1]; *ecx = cpuinfo[2]; *edx = cpuinfo[3];