From 9620f419076202ebc89b4c7f1c06374fb2554f28 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 26 Mar 2013 15:44:42 +0000 Subject: sna: Fix AVX2 detection It requires use of the cpuid feature eax=7:ecx=0, so it requires the extended version of __cpuid to pass in the subfeature. Signed-off-by: Chris Wilson --- src/sna/sna_cpu.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/sna/sna_cpu.c') diff --git a/src/sna/sna_cpu.c b/src/sna/sna_cpu.c index 13869884..ab4942b6 100644 --- a/src/sna/sna_cpu.c +++ b/src/sna/sna_cpu.c @@ -41,10 +41,12 @@ unsigned sna_cpu_detect(void) { + unsigned max = __get_cpuid_max(false, 0); unsigned int eax, ebx, ecx, edx; unsigned features = 0; - if (__get_cpuid(1, &eax, &ebx, &ecx, &edx)) { + if (max >= 1) { + __cpuid(1, eax, ebx, ecx, edx); if (ecx & bit_SSE3) features |= SSE3; @@ -70,7 +72,8 @@ unsigned sna_cpu_detect(void) features |= SSE2; } - if (__get_cpuid(7, &eax, &ebx, &ecx, &edx)) { + if (max >= 7) { + __cpuid_count(7, 0, eax, ebx, ecx, edx); if (ebx & bit_AVX2) features |= AVX2; } -- cgit v1.2.3