[committed] Check FMA after COMMON_CPUID_INDEX_80000001
Commit Message
On Fri, Jun 3, 2016 at 12:41 AM, Pawar, Amit <Amit.Pawar@amd.com> wrote:
>>... and up into the init_cpu_features (caller of get_common_indeces).
>>
>>As you refactor it up the call stack you end up copying the osxsave/xgetbv checks which get_common_indeces was already doing.
>>
>>As far as I can tell your patch just moves the check earlier... why?
> Thanks for replying and I have filed a new defect in Bugzilla as per the suggestion and please check the same https://sourceware.org/bugzilla/show_bug.cgi?id=20195
>
This patch fixes it. Tested on Intel and AMD machines. I checked
it in.
From cd560e4fff8236b079d9ed8695ff73a28b1a58e1 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 6 Jun 2016 13:57:47 -0700
Subject: [PATCH] Check FMA after COMMON_CPUID_INDEX_80000001
Since the FMA4 bit is in COMMON_CPUID_INDEX_80000001 and FMA4 requires
AVX, determine if FMA4 is usable after COMMON_CPUID_INDEX_80000001 is
available and if AVX is usable.
[BZ #20195]
* sysdeps/x86/cpu-features.c (get_common_indeces): Move FMA4
check to ...
(init_cpu_features): Here.
---
sysdeps/x86/cpu-features.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
@@ -87,10 +87,6 @@ get_common_indeces (struct cpu_features *cpu_features,
if (CPU_FEATURES_CPU_P (cpu_features, FMA))
cpu_features->feature[index_arch_FMA_Usable]
|= bit_arch_FMA_Usable;
- /* Determine if FMA4 is usable. */
- if (CPU_FEATURES_CPU_P (cpu_features, FMA4))
- cpu_features->feature[index_arch_FMA4_Usable]
- |= bit_arch_FMA4_Usable;
}
}
}
@@ -230,6 +226,15 @@ init_cpu_features (struct cpu_features *cpu_features)
cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].ecx,
cpu_features->cpuid[COMMON_CPUID_INDEX_80000001].edx);
+ if (HAS_ARCH_FEATURE (AVX_Usable))
+ {
+ /* Since the FMA4 bit is in COMMON_CPUID_INDEX_80000001 and
+ FMA4 requires AVX, determine if FMA4 is usable here. */
+ if (CPU_FEATURES_CPU_P (cpu_features, FMA4))
+ cpu_features->feature[index_arch_FMA4_Usable]
+ |= bit_arch_FMA4_Usable;
+ }
+
if (family == 0x15)
{
#if index_arch_Fast_Unaligned_Load != index_arch_Fast_Copy_Backward
--
2.5.5