forked from rpms/glibc
- Upstream patch to fix AVX testing (#801650)
This commit is contained in:
parent
6403acaa71
commit
d2e0d47266
@ -1,63 +0,0 @@
|
||||
commit afc5ed09cbce5d6fd48b3a8c5ec427b31f996880
|
||||
Author: Ulrich Drepper <drepper@gmail.com>
|
||||
Date: Thu Jan 26 07:45:14 2012 -0500
|
||||
|
||||
Reset bit_AVX in __cpu_features is OS support is missing
|
||||
|
||||
2012-01-26 Ulrich Drepper <drepper@gmail.com>
|
||||
|
||||
[BZ #13583]
|
||||
* sysdeps/x86_64/multiarch/init-arch.h: Define bit_OSXSAVE.
|
||||
* sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): If
|
||||
bit_AVX is set also check OSXAVE/XCR0 and reset bit_AVX if necessary.
|
||||
|
||||
diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c
|
||||
index 65b0ee9..4fabbee 100644
|
||||
--- a/sysdeps/x86_64/multiarch/init-arch.c
|
||||
+++ b/sysdeps/x86_64/multiarch/init-arch.c
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Initialize CPU feature data.
|
||||
This file is part of the GNU C Library.
|
||||
- Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
+ Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
||||
Contributed by Ulrich Drepper <drepper@redhat.com>.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@@ -144,6 +144,18 @@ __init_cpu_features (void)
|
||||
else
|
||||
kind = arch_kind_other;
|
||||
|
||||
+ if (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_AVX)
|
||||
+ {
|
||||
+ /* Reset the AVX bit in case OSXSAVE is disabled. */
|
||||
+ if ((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_OSXSAVE) == 0
|
||||
+ || ({ unsigned int xcrlow;
|
||||
+ unsigned int xcrhigh;
|
||||
+ asm ("xgetbv"
|
||||
+ : "=a" (xcrlow), "=d" (xcrhigh) : "c" (0));
|
||||
+ (xcrlow & 6) != 6; }))
|
||||
+ __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx &= ~bit_AVX;
|
||||
+ }
|
||||
+
|
||||
__cpu_features.family = family;
|
||||
__cpu_features.model = model;
|
||||
atomic_write_barrier ();
|
||||
diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h
|
||||
index 2a1df39..408e5ae 100644
|
||||
--- a/sysdeps/x86_64/multiarch/init-arch.h
|
||||
+++ b/sysdeps/x86_64/multiarch/init-arch.h
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This file is part of the GNU C Library.
|
||||
- Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
+ Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
@@ -27,6 +27,7 @@
|
||||
#define bit_SSSE3 (1 << 9)
|
||||
#define bit_SSE4_1 (1 << 19)
|
||||
#define bit_SSE4_2 (1 << 20)
|
||||
+#define bit_OSXSAVE (1 << 27)
|
||||
#define bit_AVX (1 << 28)
|
||||
#define bit_POPCOUNT (1 << 23)
|
||||
#define bit_FMA (1 << 12)
|
@ -1,200 +0,0 @@
|
||||
commit 08cf777f9e7f6d826658a99c7d77a359f73a45bf
|
||||
Author: Ulrich Drepper <drepper@gmail.com>
|
||||
Date: Thu Jan 26 09:45:54 2012 -0500
|
||||
|
||||
Really fix AVX tests
|
||||
|
||||
There is no problem with strcmp, it doesn't use the YMM registers.
|
||||
The math routines might since gcc perhaps generates such code.
|
||||
Introduce bit_YMM_USBALE and use it in the math routines.
|
||||
|
||||
[BZ #13583]
|
||||
* sysdeps/x86_64/multiarch/init-arch.h: Define bit_OSXSAVE.
|
||||
Clean up HAS_* macros.
|
||||
* sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): If
|
||||
bit_AVX is set also check OSXAVE/XCR0 and set bit_YMM_Usable if
|
||||
possible.
|
||||
* sysdeps/x86_64/fpu/multiarch/e_atan2.c: Use HAS_YMM_USABLE, not
|
||||
HAS_AVX.
|
||||
* sysdeps/x86_64/fpu/multiarch/e_exp.c: Likewise.
|
||||
* sysdeps/x86_64/fpu/multiarch/e_log.c: Likewise.
|
||||
* sysdeps/x86_64/fpu/multiarch/s_atan.c: Likewise.
|
||||
* sysdeps/x86_64/fpu/multiarch/s_sin.c: Likewise.
|
||||
* sysdeps/x86_64/fpu/multiarch/s_tan.c: Likewise.
|
||||
|
||||
2012-01-25 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
diff --git a/sysdeps/x86_64/fpu/multiarch/e_atan2.c b/sysdeps/x86_64/fpu/multiarch/e_atan2.c
|
||||
index 6867c6e..3a615fc 100644
|
||||
--- a/sysdeps/x86_64/fpu/multiarch/e_atan2.c
|
||||
+++ b/sysdeps/x86_64/fpu/multiarch/e_atan2.c
|
||||
@@ -14,7 +14,7 @@ extern double __ieee754_atan2_fma4 (double, double);
|
||||
|
||||
libm_ifunc (__ieee754_atan2,
|
||||
HAS_FMA4 ? __ieee754_atan2_fma4
|
||||
- : (HAS_AVX ? __ieee754_atan2_avx : __ieee754_atan2_sse2));
|
||||
+ : (HAS_YMM_USABLE ? __ieee754_atan2_avx : __ieee754_atan2_sse2));
|
||||
strong_alias (__ieee754_atan2, __atan2_finite)
|
||||
|
||||
# define __ieee754_atan2 __ieee754_atan2_sse2
|
||||
diff --git a/sysdeps/x86_64/fpu/multiarch/e_exp.c b/sysdeps/x86_64/fpu/multiarch/e_exp.c
|
||||
index 3c65028..7b2320a 100644
|
||||
--- a/sysdeps/x86_64/fpu/multiarch/e_exp.c
|
||||
+++ b/sysdeps/x86_64/fpu/multiarch/e_exp.c
|
||||
@@ -14,7 +14,7 @@ extern double __ieee754_exp_fma4 (double);
|
||||
|
||||
libm_ifunc (__ieee754_exp,
|
||||
HAS_FMA4 ? __ieee754_exp_fma4
|
||||
- : (HAS_AVX ? __ieee754_exp_avx : __ieee754_exp_sse2));
|
||||
+ : (HAS_YMM_USABLE ? __ieee754_exp_avx : __ieee754_exp_sse2));
|
||||
strong_alias (__ieee754_exp, __exp_finite)
|
||||
|
||||
# define __ieee754_exp __ieee754_exp_sse2
|
||||
diff --git a/sysdeps/x86_64/fpu/multiarch/e_log.c b/sysdeps/x86_64/fpu/multiarch/e_log.c
|
||||
index 3b468d0..ab277d6 100644
|
||||
--- a/sysdeps/x86_64/fpu/multiarch/e_log.c
|
||||
+++ b/sysdeps/x86_64/fpu/multiarch/e_log.c
|
||||
@@ -14,7 +14,7 @@ extern double __ieee754_log_fma4 (double);
|
||||
|
||||
libm_ifunc (__ieee754_log,
|
||||
HAS_FMA4 ? __ieee754_log_fma4
|
||||
- : (HAS_AVX ? __ieee754_log_avx
|
||||
+ : (HAS_YMM_USABLE ? __ieee754_log_avx
|
||||
: __ieee754_log_sse2));
|
||||
strong_alias (__ieee754_log, __log_finite)
|
||||
|
||||
diff --git a/sysdeps/x86_64/fpu/multiarch/s_atan.c b/sysdeps/x86_64/fpu/multiarch/s_atan.c
|
||||
index 3160201..78c7e09 100644
|
||||
--- a/sysdeps/x86_64/fpu/multiarch/s_atan.c
|
||||
+++ b/sysdeps/x86_64/fpu/multiarch/s_atan.c
|
||||
@@ -12,7 +12,8 @@ extern double __atan_fma4 (double);
|
||||
# define __atan_fma4 ((void *) 0)
|
||||
# endif
|
||||
|
||||
-libm_ifunc (atan, HAS_FMA4 ? __atan_fma4 : HAS_AVX ? __atan_avx : __atan_sse2);
|
||||
+libm_ifunc (atan, (HAS_FMA4 ? __atan_fma4 :
|
||||
+ HAS_YMM_USABLE ? __atan_avx : __atan_sse2));
|
||||
|
||||
# define atan __atan_sse2
|
||||
#endif
|
||||
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sin.c b/sysdeps/x86_64/fpu/multiarch/s_sin.c
|
||||
index 1ba9dbc..417acd0 100644
|
||||
--- a/sysdeps/x86_64/fpu/multiarch/s_sin.c
|
||||
+++ b/sysdeps/x86_64/fpu/multiarch/s_sin.c
|
||||
@@ -17,10 +17,12 @@ extern double __sin_fma4 (double);
|
||||
# define __sin_fma4 ((void *) 0)
|
||||
# endif
|
||||
|
||||
-libm_ifunc (__cos, HAS_FMA4 ? __cos_fma4 : HAS_AVX ? __cos_avx : __cos_sse2);
|
||||
+libm_ifunc (__cos, (HAS_FMA4 ? __cos_fma4 :
|
||||
+ HAS_YMM_USABLE ? __cos_avx : __cos_sse2));
|
||||
weak_alias (__cos, cos)
|
||||
|
||||
-libm_ifunc (__sin, HAS_FMA4 ? __sin_fma4 : HAS_AVX ? __sin_avx : __sin_sse2);
|
||||
+libm_ifunc (__sin, (HAS_FMA4 ? __sin_fma4 :
|
||||
+ HAS_YMM_USABLE ? __sin_avx : __sin_sse2));
|
||||
weak_alias (__sin, sin)
|
||||
|
||||
# define __cos __cos_sse2
|
||||
diff --git a/sysdeps/x86_64/fpu/multiarch/s_tan.c b/sysdeps/x86_64/fpu/multiarch/s_tan.c
|
||||
index 8f6601e..3047155 100644
|
||||
--- a/sysdeps/x86_64/fpu/multiarch/s_tan.c
|
||||
+++ b/sysdeps/x86_64/fpu/multiarch/s_tan.c
|
||||
@@ -12,7 +12,8 @@ extern double __tan_fma4 (double);
|
||||
# define __tan_fma4 ((void *) 0)
|
||||
# endif
|
||||
|
||||
-libm_ifunc (tan, HAS_FMA4 ? __tan_fma4 : HAS_AVX ? __tan_avx : __tan_sse2);
|
||||
+libm_ifunc (tan, (HAS_FMA4 ? __tan_fma4 :
|
||||
+ HAS_YMM_USABLE ? __tan_avx : __tan_sse2));
|
||||
|
||||
# define tan __tan_sse2
|
||||
#endif
|
||||
diff --git a/sysdeps/x86_64/multiarch/init-arch.c b/sysdeps/x86_64/multiarch/init-arch.c
|
||||
index 4fabbee..76d146c 100644
|
||||
--- a/sysdeps/x86_64/multiarch/init-arch.c
|
||||
+++ b/sysdeps/x86_64/multiarch/init-arch.c
|
||||
@@ -147,13 +147,13 @@ __init_cpu_features (void)
|
||||
if (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_AVX)
|
||||
{
|
||||
/* Reset the AVX bit in case OSXSAVE is disabled. */
|
||||
- if ((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_OSXSAVE) == 0
|
||||
- || ({ unsigned int xcrlow;
|
||||
- unsigned int xcrhigh;
|
||||
- asm ("xgetbv"
|
||||
- : "=a" (xcrlow), "=d" (xcrhigh) : "c" (0));
|
||||
- (xcrlow & 6) != 6; }))
|
||||
- __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx &= ~bit_AVX;
|
||||
+ if ((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_OSXSAVE) != 0
|
||||
+ && ({ unsigned int xcrlow;
|
||||
+ unsigned int xcrhigh;
|
||||
+ asm ("xgetbv"
|
||||
+ : "=a" (xcrlow), "=d" (xcrhigh) : "c" (0));
|
||||
+ (xcrlow & 6) == 6; }))
|
||||
+ __cpu_features.feature[index_YMM_Usable] |= bit_YMM_Usable;
|
||||
}
|
||||
|
||||
__cpu_features.family = family;
|
||||
diff --git a/sysdeps/x86_64/multiarch/init-arch.h b/sysdeps/x86_64/multiarch/init-arch.h
|
||||
index 408e5ae..2dc75ab 100644
|
||||
--- a/sysdeps/x86_64/multiarch/init-arch.h
|
||||
+++ b/sysdeps/x86_64/multiarch/init-arch.h
|
||||
@@ -22,6 +22,7 @@
|
||||
#define bit_Prefer_SSE_for_memop (1 << 3)
|
||||
#define bit_Fast_Unaligned_Load (1 << 4)
|
||||
#define bit_Prefer_PMINUB_for_stringop (1 << 5)
|
||||
+#define bit_YMM_Usable (1 << 6)
|
||||
|
||||
#define bit_SSE2 (1 << 26)
|
||||
#define bit_SSSE3 (1 << 9)
|
||||
@@ -49,6 +50,7 @@
|
||||
# define index_Prefer_SSE_for_memop FEATURE_INDEX_1*FEATURE_SIZE
|
||||
# define index_Fast_Unaligned_Load FEATURE_INDEX_1*FEATURE_SIZE
|
||||
# define index_Prefer_PMINUB_for_stringop FEATURE_INDEX_1*FEATURE_SIZE
|
||||
+# define index_YMM_Usable FEATURE_INDEX_1*FEATURE_SIZE
|
||||
|
||||
#else /* __ASSEMBLER__ */
|
||||
|
||||
@@ -93,7 +95,7 @@ extern struct cpu_features
|
||||
|
||||
|
||||
extern void __init_cpu_features (void) attribute_hidden;
|
||||
-#define INIT_ARCH()\
|
||||
+# define INIT_ARCH() \
|
||||
do \
|
||||
if (__cpu_features.kind == arch_kind_unknown) \
|
||||
__init_cpu_features (); \
|
||||
@@ -126,23 +128,21 @@ extern const struct cpu_features *__get_cpu_features (void)
|
||||
# define index_Slow_BSF FEATURE_INDEX_1
|
||||
# define index_Prefer_SSE_for_memop FEATURE_INDEX_1
|
||||
# define index_Fast_Unaligned_Load FEATURE_INDEX_1
|
||||
+# define index_YMM_Usable FEATURE_INDEX_1
|
||||
|
||||
-#define HAS_ARCH_FEATURE(idx, bit) \
|
||||
- ((__get_cpu_features ()->feature[idx] & (bit)) != 0)
|
||||
+# define HAS_ARCH_FEATURE(name) \
|
||||
+ ((__get_cpu_features ()->feature[index_##name] & (bit_##name)) != 0)
|
||||
|
||||
-#define HAS_FAST_REP_STRING \
|
||||
- HAS_ARCH_FEATURE (index_Fast_Rep_String, bit_Fast_Rep_String)
|
||||
+# define HAS_FAST_REP_STRING HAS_ARCH_FEATURE (Fast_Rep_String)
|
||||
|
||||
-#define HAS_FAST_COPY_BACKWARD \
|
||||
- HAS_ARCH_FEATURE (index_Fast_Copy_Backward, bit_Fast_Copy_Backward)
|
||||
+# define HAS_FAST_COPY_BACKWARD HAS_ARCH_FEATURE (Fast_Copy_Backward)
|
||||
|
||||
-#define HAS_SLOW_BSF \
|
||||
- HAS_ARCH_FEATURE (index_Slow_BSF, bit_Slow_BSF)
|
||||
+# define HAS_SLOW_BSF HAS_ARCH_FEATURE (Slow_BSF)
|
||||
|
||||
-#define HAS_PREFER_SSE_FOR_MEMOP \
|
||||
- HAS_ARCH_FEATURE (index_Prefer_SSE_for_memop, bit_Prefer_SSE_for_memop)
|
||||
+# define HAS_PREFER_SSE_FOR_MEMOP HAS_ARCH_FEATURE (Prefer_SSE_for_memop)
|
||||
|
||||
-#define HAS_FAST_UNALIGNED_LOAD \
|
||||
- HAS_ARCH_FEATURE (index_Fast_Unaligned_Load, bit_Fast_Unaligned_Load)
|
||||
+# define HAS_FAST_UNALIGNED_LOAD HAS_ARCH_FEATURE (Fast_Unaligned_Load)
|
||||
+
|
||||
+# define HAS_YMM_USABLE HAS_ARCH_FEATURE (YMM_Usable)
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
@ -1,12 +0,0 @@
|
||||
diff -rup c/sysdeps/x86_64/multiarch/init-arch.c d/sysdeps/x86_64/multiarch/init-arch.c
|
||||
--- c/sysdeps/x86_64/multiarch/init-arch.c 2012-05-10 14:06:54.607713791 -0600
|
||||
+++ d/sysdeps/x86_64/multiarch/init-arch.c 2012-05-10 14:15:37.855008615 -0600
|
||||
@@ -154,6 +154,8 @@ __init_cpu_features (void)
|
||||
: "=a" (xcrlow), "=d" (xcrhigh) : "c" (0));
|
||||
(xcrlow & 6) == 6; }))
|
||||
__cpu_features.feature[index_YMM_Usable] |= bit_YMM_Usable;
|
||||
+ else
|
||||
+ __cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx &= ~bit_AVX;
|
||||
}
|
||||
|
||||
__cpu_features.family = family;
|
253
glibc-rh801650.patch
Normal file
253
glibc-rh801650.patch
Normal file
@ -0,0 +1,253 @@
|
||||
diff -rup c/sysdeps/x86_64/fpu/multiarch/e_log.c d/sysdeps/x86_64/fpu/multiarch/e_log.c
|
||||
--- c/sysdeps/x86_64/fpu/multiarch/e_log.c 2012-01-01 05:16:32.000000000 -0700
|
||||
+++ d/sysdeps/x86_64/fpu/multiarch/e_log.c 2012-05-11 12:53:39.491061476 -0600
|
||||
@@ -14,8 +14,7 @@ extern double __ieee754_log_fma4 (double
|
||||
|
||||
libm_ifunc (__ieee754_log,
|
||||
HAS_FMA4 ? __ieee754_log_fma4
|
||||
- : (HAS_AVX ? __ieee754_log_avx
|
||||
- : __ieee754_log_sse2));
|
||||
+ : (HAS_AVX ? __ieee754_log_avx : __ieee754_log_sse2));
|
||||
strong_alias (__ieee754_log, __log_finite)
|
||||
|
||||
# define __ieee754_log __ieee754_log_sse2
|
||||
diff -rup c/sysdeps/x86_64/fpu/multiarch/s_atan.c d/sysdeps/x86_64/fpu/multiarch/s_atan.c
|
||||
--- c/sysdeps/x86_64/fpu/multiarch/s_atan.c 2012-01-01 05:16:32.000000000 -0700
|
||||
+++ d/sysdeps/x86_64/fpu/multiarch/s_atan.c 2012-05-11 12:53:39.491061476 -0600
|
||||
@@ -12,7 +12,8 @@ extern double __atan_fma4 (double);
|
||||
# define __atan_fma4 ((void *) 0)
|
||||
# endif
|
||||
|
||||
-libm_ifunc (atan, HAS_FMA4 ? __atan_fma4 : HAS_AVX ? __atan_avx : __atan_sse2);
|
||||
+libm_ifunc (atan, (HAS_FMA4 ? __atan_fma4 :
|
||||
+ HAS_AVX ? __atan_avx : __atan_sse2));
|
||||
|
||||
# define atan __atan_sse2
|
||||
#endif
|
||||
diff -rup c/sysdeps/x86_64/fpu/multiarch/s_sin.c d/sysdeps/x86_64/fpu/multiarch/s_sin.c
|
||||
--- c/sysdeps/x86_64/fpu/multiarch/s_sin.c 2012-01-01 05:16:32.000000000 -0700
|
||||
+++ d/sysdeps/x86_64/fpu/multiarch/s_sin.c 2012-05-11 12:53:39.491061476 -0600
|
||||
@@ -17,10 +17,12 @@ extern double __sin_fma4 (double);
|
||||
# define __sin_fma4 ((void *) 0)
|
||||
# endif
|
||||
|
||||
-libm_ifunc (__cos, HAS_FMA4 ? __cos_fma4 : HAS_AVX ? __cos_avx : __cos_sse2);
|
||||
+libm_ifunc (__cos, (HAS_FMA4 ? __cos_fma4 :
|
||||
+ HAS_AVX ? __cos_avx : __cos_sse2));
|
||||
weak_alias (__cos, cos)
|
||||
|
||||
-libm_ifunc (__sin, HAS_FMA4 ? __sin_fma4 : HAS_AVX ? __sin_avx : __sin_sse2);
|
||||
+libm_ifunc (__sin, (HAS_FMA4 ? __sin_fma4 :
|
||||
+ HAS_AVX ? __sin_avx : __sin_sse2));
|
||||
weak_alias (__sin, sin)
|
||||
|
||||
# define __cos __cos_sse2
|
||||
diff -rup c/sysdeps/x86_64/fpu/multiarch/s_tan.c d/sysdeps/x86_64/fpu/multiarch/s_tan.c
|
||||
--- c/sysdeps/x86_64/fpu/multiarch/s_tan.c 2012-01-01 05:16:32.000000000 -0700
|
||||
+++ d/sysdeps/x86_64/fpu/multiarch/s_tan.c 2012-05-11 12:53:39.491061476 -0600
|
||||
@@ -12,7 +12,8 @@ extern double __tan_fma4 (double);
|
||||
# define __tan_fma4 ((void *) 0)
|
||||
# endif
|
||||
|
||||
-libm_ifunc (tan, HAS_FMA4 ? __tan_fma4 : HAS_AVX ? __tan_avx : __tan_sse2);
|
||||
+libm_ifunc (tan, (HAS_FMA4 ? __tan_fma4 :
|
||||
+ HAS_AVX ? __tan_avx : __tan_sse2));
|
||||
|
||||
# define tan __tan_sse2
|
||||
#endif
|
||||
diff -rup c/sysdeps/x86_64/multiarch/init-arch.c d/sysdeps/x86_64/multiarch/init-arch.c
|
||||
--- c/sysdeps/x86_64/multiarch/init-arch.c 2012-01-01 05:16:32.000000000 -0700
|
||||
+++ d/sysdeps/x86_64/multiarch/init-arch.c 2012-05-11 12:55:29.169490958 -0600
|
||||
@@ -1,6 +1,6 @@
|
||||
/* Initialize CPU feature data.
|
||||
This file is part of the GNU C Library.
|
||||
- Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
+ Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
||||
Contributed by Ulrich Drepper <drepper@redhat.com>.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@@ -14,9 +14,8 @@
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
- License along with the GNU C Library; if not, write to the Free
|
||||
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
- 02111-1307 USA. */
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <atomic.h>
|
||||
#include <cpuid.h>
|
||||
@@ -144,6 +143,23 @@ __init_cpu_features (void)
|
||||
else
|
||||
kind = arch_kind_other;
|
||||
|
||||
+ if (__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_AVX)
|
||||
+ {
|
||||
+ /* Determine if AVX is usable. */
|
||||
+ if ((__cpu_features.cpuid[COMMON_CPUID_INDEX_1].ecx & bit_OSXSAVE) != 0
|
||||
+ && ({ unsigned int xcrlow;
|
||||
+ unsigned int xcrhigh;
|
||||
+ asm ("xgetbv"
|
||||
+ : "=a" (xcrlow), "=d" (xcrhigh) : "c" (0));
|
||||
+ (xcrlow & (bit_YMM_state | bit_XMM_state)) ==
|
||||
+ (bit_YMM_state | bit_XMM_state); }))
|
||||
+ __cpu_features.feature[index_AVX_Usable] = 1;
|
||||
+ }
|
||||
+
|
||||
+ /* FMA4 depends on AVX support. */
|
||||
+ if ((__cpu_features.cpuid[COMMON_CPUID_INDEX_80000001].ecx & bit_FMA4) && __cpu_features.feature[index_AVX_Usable])
|
||||
+ __cpu_features.feature[index_FMA4_Usable] = 1;
|
||||
+
|
||||
__cpu_features.family = family;
|
||||
__cpu_features.model = model;
|
||||
atomic_write_barrier ();
|
||||
diff -rup c/sysdeps/x86_64/multiarch/init-arch.h d/sysdeps/x86_64/multiarch/init-arch.h
|
||||
--- c/sysdeps/x86_64/multiarch/init-arch.h 2012-01-01 05:16:32.000000000 -0700
|
||||
+++ d/sysdeps/x86_64/multiarch/init-arch.h 2012-05-11 12:55:29.170490953 -0600
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This file is part of the GNU C Library.
|
||||
- Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
+ Copyright (C) 2008-2012 Free Software Foundation, Inc.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
@@ -12,9 +12,8 @@
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
- License along with the GNU C Library; if not, write to the Free
|
||||
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
- 02111-1307 USA. */
|
||||
+ License along with the GNU C Library; if not, see
|
||||
+ <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#define bit_Fast_Rep_String (1 << 0)
|
||||
#define bit_Fast_Copy_Backward (1 << 1)
|
||||
@@ -22,16 +21,24 @@
|
||||
#define bit_Prefer_SSE_for_memop (1 << 3)
|
||||
#define bit_Fast_Unaligned_Load (1 << 4)
|
||||
#define bit_Prefer_PMINUB_for_stringop (1 << 5)
|
||||
+#define bit_AVX_Usable (1 << 6)
|
||||
+#define bit_FMA4_Usable (1 << 7)
|
||||
|
||||
+/* CPUID Feature flags. */
|
||||
#define bit_SSE2 (1 << 26)
|
||||
#define bit_SSSE3 (1 << 9)
|
||||
#define bit_SSE4_1 (1 << 19)
|
||||
#define bit_SSE4_2 (1 << 20)
|
||||
+#define bit_OSXSAVE (1 << 27)
|
||||
#define bit_AVX (1 << 28)
|
||||
#define bit_POPCOUNT (1 << 23)
|
||||
#define bit_FMA (1 << 12)
|
||||
#define bit_FMA4 (1 << 16)
|
||||
|
||||
+/* XCR0 Feature flags. */
|
||||
+#define bit_XMM_state (1 << 1)
|
||||
+#define bit_YMM_state (2 << 1)
|
||||
+
|
||||
#ifdef __ASSEMBLER__
|
||||
|
||||
# include <ifunc-defines.h>
|
||||
@@ -48,6 +55,8 @@
|
||||
# define index_Prefer_SSE_for_memop FEATURE_INDEX_1*FEATURE_SIZE
|
||||
# define index_Fast_Unaligned_Load FEATURE_INDEX_1*FEATURE_SIZE
|
||||
# define index_Prefer_PMINUB_for_stringop FEATURE_INDEX_1*FEATURE_SIZE
|
||||
+# define index_AVX_Usable FEATURE_INDEX_1*FEATURE_SIZE
|
||||
+# define index_FMA4_Usable FEATURE_INDEX_1*FEATURE_SIZE
|
||||
|
||||
#else /* __ASSEMBLER__ */
|
||||
|
||||
@@ -92,7 +101,7 @@ extern struct cpu_features
|
||||
|
||||
|
||||
extern void __init_cpu_features (void) attribute_hidden;
|
||||
-#define INIT_ARCH()\
|
||||
+# define INIT_ARCH() \
|
||||
do \
|
||||
if (__cpu_features.kind == arch_kind_unknown) \
|
||||
__init_cpu_features (); \
|
||||
@@ -111,37 +120,36 @@ extern const struct cpu_features *__get_
|
||||
|
||||
/* Following are the feature tests used throughout libc. */
|
||||
|
||||
+/* CPUID_* evaluates to true if the feature flag is enabled. */
|
||||
+# define CPUID_OSXSAVE HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_OSXSAVE)
|
||||
+# define CPUID_AVX HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_AVX)
|
||||
+# define CPUID_FMA4 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_80000001, ecx, bit_FMA4)
|
||||
+
|
||||
+/* HAS_* evaluates to true if we may use the feature at runtime. */
|
||||
# define HAS_SSE2 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, edx, bit_SSE2)
|
||||
# define HAS_POPCOUNT HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_POPCOUNT)
|
||||
# define HAS_SSSE3 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSSE3)
|
||||
# define HAS_SSE4_1 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSE4_1)
|
||||
# define HAS_SSE4_2 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_SSE4_2)
|
||||
# define HAS_FMA HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_FMA)
|
||||
-# define HAS_AVX HAS_CPU_FEATURE (COMMON_CPUID_INDEX_1, ecx, bit_AVX)
|
||||
-# define HAS_FMA4 HAS_CPU_FEATURE (COMMON_CPUID_INDEX_80000001, ecx, bit_FMA4)
|
||||
|
||||
# define index_Fast_Rep_String FEATURE_INDEX_1
|
||||
# define index_Fast_Copy_Backward FEATURE_INDEX_1
|
||||
# define index_Slow_BSF FEATURE_INDEX_1
|
||||
# define index_Prefer_SSE_for_memop FEATURE_INDEX_1
|
||||
# define index_Fast_Unaligned_Load FEATURE_INDEX_1
|
||||
+# define index_AVX_Usable FEATURE_INDEX_1
|
||||
+# define index_FMA4_Usable FEATURE_INDEX_1
|
||||
|
||||
-#define HAS_ARCH_FEATURE(idx, bit) \
|
||||
- ((__get_cpu_features ()->feature[idx] & (bit)) != 0)
|
||||
-
|
||||
-#define HAS_FAST_REP_STRING \
|
||||
- HAS_ARCH_FEATURE (index_Fast_Rep_String, bit_Fast_Rep_String)
|
||||
-
|
||||
-#define HAS_FAST_COPY_BACKWARD \
|
||||
- HAS_ARCH_FEATURE (index_Fast_Copy_Backward, bit_Fast_Copy_Backward)
|
||||
-
|
||||
-#define HAS_SLOW_BSF \
|
||||
- HAS_ARCH_FEATURE (index_Slow_BSF, bit_Slow_BSF)
|
||||
-
|
||||
-#define HAS_PREFER_SSE_FOR_MEMOP \
|
||||
- HAS_ARCH_FEATURE (index_Prefer_SSE_for_memop, bit_Prefer_SSE_for_memop)
|
||||
+# define HAS_ARCH_FEATURE(name) \
|
||||
+ ((__get_cpu_features ()->feature[index_##name] & (bit_##name)) != 0)
|
||||
|
||||
-#define HAS_FAST_UNALIGNED_LOAD \
|
||||
- HAS_ARCH_FEATURE (index_Fast_Unaligned_Load, bit_Fast_Unaligned_Load)
|
||||
+# define HAS_FAST_REP_STRING HAS_ARCH_FEATURE (Fast_Rep_String)
|
||||
+# define HAS_FAST_COPY_BACKWARD HAS_ARCH_FEATURE (Fast_Copy_Backward)
|
||||
+# define HAS_SLOW_BSF HAS_ARCH_FEATURE (Slow_BSF)
|
||||
+# define HAS_PREFER_SSE_FOR_MEMOP HAS_ARCH_FEATURE (Prefer_SSE_for_memop)
|
||||
+# define HAS_FAST_UNALIGNED_LOAD HAS_ARCH_FEATURE (Fast_Unaligned_Load)
|
||||
+# define HAS_AVX HAS_ARCH_FEATURE (AVX_Usable)
|
||||
+# define HAS_FMA4 HAS_ARCH_FEATURE (FMA4_Usable)
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
diff -rup c/sysdeps/x86_64/multiarch/strcmp.S d/sysdeps/x86_64/multiarch/strcmp.S
|
||||
--- c/sysdeps/x86_64/multiarch/strcmp.S 2012-01-01 05:16:32.000000000 -0700
|
||||
+++ d/sysdeps/x86_64/multiarch/strcmp.S 2012-05-11 12:55:29.172490943 -0600
|
||||
@@ -1,5 +1,5 @@
|
||||
/* strcmp with SSE4.2
|
||||
- Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||
+ Copyright (C) 2009-2012 Free Software Foundation, Inc.
|
||||
Contributed by Intel Corporation.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@@ -107,7 +107,7 @@ ENTRY(__strcasecmp)
|
||||
1:
|
||||
# ifdef HAVE_AVX_SUPPORT
|
||||
leaq __strcasecmp_avx(%rip), %rax
|
||||
- testl $bit_AVX, __cpu_features+CPUID_OFFSET+index_AVX(%rip)
|
||||
+ testl $bit_AVX_Usable, __cpu_features+FEATURE_OFFSET+index_AVX_Usable(%rip)
|
||||
jnz 2f
|
||||
# endif
|
||||
leaq __strcasecmp_sse42(%rip), %rax
|
||||
@@ -130,7 +130,7 @@ ENTRY(__strncasecmp)
|
||||
1:
|
||||
# ifdef HAVE_AVX_SUPPORT
|
||||
leaq __strncasecmp_avx(%rip), %rax
|
||||
- testl $bit_AVX, __cpu_features+CPUID_OFFSET+index_AVX(%rip)
|
||||
+ testl $bit_AVX_Usable, __cpu_features+FEATURE_OFFSET+index_AVX_Usable(%rip)
|
||||
jnz 2f
|
||||
# endif
|
||||
leaq __strncasecmp_sse42(%rip), %rax
|
||||
Only in d/sysdeps/x86_64/multiarch: strcmp.S.orig
|
13
glibc.spec
13
glibc.spec
@ -28,7 +28,7 @@
|
||||
Summary: The GNU libc libraries
|
||||
Name: glibc
|
||||
Version: %{glibcversion}
|
||||
Release: 37%{?dist}
|
||||
Release: 38%{?dist}
|
||||
# GPLv2+ is used in a bunch of programs, LGPLv2+ is used for libraries.
|
||||
# Things that are linked directly into dynamically linked programs
|
||||
# and shared libraries (e.g. crt files, lib*_nonshared.a) have an additional
|
||||
@ -108,8 +108,6 @@ Patch1037: %{name}-rh760935.patch
|
||||
Patch1038: %{name}-rh798471.patch
|
||||
Patch1039: %{name}-rh758888.patch
|
||||
Patch1041: %{name}-rh794797-2.patch
|
||||
Patch1042: %{name}-rh801650-1.patch
|
||||
Patch1043: %{name}-rh801650-2.patch
|
||||
Patch1046: %{name}-rh806403.patch
|
||||
Patch1048: %{name}-rh804792.patch
|
||||
Patch1052: %{name}-sw13979.patch
|
||||
@ -190,8 +188,8 @@ Patch2051: %{name}-rh788989-2.patch
|
||||
Patch2054: %{name}-arm-hardfloat-1.patch
|
||||
Patch2055: %{name}-arm-hardfloat-2.patch
|
||||
|
||||
# Upstream BZ 13753, probably will be fixed differently
|
||||
Patch2056: %{name}-rh801650-3.patch
|
||||
# Upstream BZ 13753/14059
|
||||
Patch2056: %{name}-rh801650.patch
|
||||
|
||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
Obsoletes: glibc-profile < 2.4
|
||||
@ -448,8 +446,6 @@ rm -rf %{glibcportsdir}
|
||||
%patch1039 -p1
|
||||
%patch2040 -p1
|
||||
%patch1041 -p1
|
||||
%patch1042 -p1
|
||||
%patch1043 -p1
|
||||
%patch0044 -p1
|
||||
%patch2045 -p1
|
||||
%patch1046 -p1
|
||||
@ -1319,6 +1315,9 @@ rm -f *.filelist*
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri May 11 2012 Jeff Law <law@redhat.com> - 2.15-38
|
||||
- Upstream patch to fix AVX testing (#801650)
|
||||
|
||||
* Thu May 10 2012 Jeff Law <law@redhat.com> - 2.15-37
|
||||
- Try again to fix AVX testing (#801650)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user