Skip to content

Commit 38c313a

Browse files
committed
fma 3 still requires OSXSAVE
1 parent e6f7cd9 commit 38c313a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

cpuid.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,9 @@ func support() flagSet {
844844
if vend == AMD && (d&(1<<28)) != 0 && mfi >= 4 {
845845
fs.setIf(threadsPerCore() > 1, HTT)
846846
}
847-
// Check XGETBV, OXSAVE and AVX bits
848-
if c&(1<<26) != 0 && c&(1<<27) != 0 && c&(1<<28) != 0 {
847+
// Check XGETBV/XSAVE (26), OXSAVE (27) and AVX (28) bits
848+
const avxCheck = 1<<26 | 1<<27 | 1<<28
849+
if c&avxCheck == avxCheck {
849850
// Check for OS support
850851
eax, _ := xgetbv(0)
851852
if (eax & 0x6) == 0x6 {
@@ -861,7 +862,9 @@ func support() flagSet {
861862
}
862863
}
863864
// FMA3 can be used with SSE registers, so no OS support is strictly needed.
864-
fs.setIf((c&0x00001000) != 0, FMA3)
865+
// fma3 and OSXSAVE needed.
866+
const fma3Check = 1<<12 | 1<<27
867+
fs.setIf(c&fma3Check == fma3Check, FMA3)
865868

866869
// Check AVX2, AVX2 requires OS support, but BMI1/2 don't.
867870
if mfi >= 7 {

0 commit comments

Comments
 (0)