This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: Properly check AVX support in _dl_runtime_profile
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Cc: Ulrich Drepper <drepper at gmail dot com>
- Date: Fri, 22 Jul 2011 05:22:47 -0700
- Subject: PATCH: Properly check AVX support in _dl_runtime_profile
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi Ulrich,
This patch fixes the AVX support in _dl_runtime_profile. Tested on
Fedora 15/x86-64 with and without AVX.
H.J.
---
2011-07-22 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_profile): Properly
check AVX support.
diff --git a/sysdeps/x86_64/dl-trampoline.S b/sysdeps/x86_64/dl-trampoline.S
index 1b97929..1707c05 100644
--- a/sysdeps/x86_64/dl-trampoline.S
+++ b/sysdeps/x86_64/dl-trampoline.S
@@ -139,19 +139,20 @@ L(have_avx):
movl $1, %eax
cpuid
movq %r11,%rbx # Restore rbx
- xorl %eax, %eax
+ movl $-1, %edi
// AVX and XSAVE supported?
- testl $((1 << 28) | (1 << 27)), %ecx
- je 2f
+ andl $((1 << 28) | (1 << 27)), %ecx
+ cmpl $((1 << 28) | (1 << 27)), %ecx
+ jne 2f
xorl %ecx, %ecx
// Get XFEATURE_ENABLED_MASK
xgetbv
andl $0x6, %eax
cmpl $0x6, %eax
// Nonzero if SSE and AVX state saving is enabled.
- sete %al
-2: movl %eax, L(have_avx)(%rip)
- cmpl $0, %eax
+ cmove %eax, %edi
+2: movl %edi, L(have_avx)(%rip)
+ cmpl $0, %edi
1: js L(no_avx)