mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: use internal/cpu.X86.HasAVX2 instead of support_avx2
After CL 104636 cpu.X86.HasAVX is set early enough that it can be used in runtime·memclrNoHeapPointers. Add an offset to use in assembly and replace the only occurence of support_avx2. Change-Id: Icada62efeb3e24d71251d55623a8a8602364c9a8 Reviewed-on: https://go-review.googlesource.com/106595 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
This commit is contained in:
parent
284ba47b49
commit
d0712096b3
6 changed files with 14 additions and 30 deletions
|
|
@ -184,11 +184,6 @@ eax7:
|
||||||
MOVL $0, CX
|
MOVL $0, CX
|
||||||
CPUID
|
CPUID
|
||||||
|
|
||||||
// If OS support for XMM and YMM is not present
|
|
||||||
// support_avx2 will be set back to false later.
|
|
||||||
TESTL $(1<<5), BX
|
|
||||||
SETNE runtime·support_avx2(SB)
|
|
||||||
|
|
||||||
TESTL $(1<<9), BX // ERMS
|
TESTL $(1<<9), BX // ERMS
|
||||||
SETNE runtime·support_erms(SB)
|
SETNE runtime·support_erms(SB)
|
||||||
|
|
||||||
|
|
@ -197,16 +192,13 @@ osavx:
|
||||||
// for XMM and YMM OS support.
|
// for XMM and YMM OS support.
|
||||||
#ifndef GOOS_nacl
|
#ifndef GOOS_nacl
|
||||||
CMPB runtime·support_osxsave(SB), $1
|
CMPB runtime·support_osxsave(SB), $1
|
||||||
JNE noavx
|
JNE nocpuinfo
|
||||||
MOVL $0, CX
|
MOVL $0, CX
|
||||||
// For XGETBV, OSXSAVE bit is required and sufficient
|
// For XGETBV, OSXSAVE bit is required and sufficient
|
||||||
XGETBV
|
XGETBV
|
||||||
ANDL $6, AX
|
ANDL $6, AX
|
||||||
CMPL AX, $6 // Check for OS support of XMM and YMM registers.
|
CMPL AX, $6 // Check for OS support of XMM and YMM registers.
|
||||||
JE nocpuinfo
|
|
||||||
#endif
|
#endif
|
||||||
noavx:
|
|
||||||
MOVB $0, runtime·support_avx2(SB)
|
|
||||||
|
|
||||||
nocpuinfo:
|
nocpuinfo:
|
||||||
// if there is an _cgo_init, call it to let it
|
// if there is an _cgo_init, call it to let it
|
||||||
|
|
|
||||||
|
|
@ -147,25 +147,17 @@ eax7:
|
||||||
MOVL $0, CX
|
MOVL $0, CX
|
||||||
CPUID
|
CPUID
|
||||||
|
|
||||||
// If OS support for XMM and YMM is not present
|
|
||||||
// support_avx2 will be set back to false later.
|
|
||||||
TESTL $(1<<5), BX
|
|
||||||
SETNE runtime·support_avx2(SB)
|
|
||||||
|
|
||||||
TESTL $(1<<9), BX // ERMS
|
TESTL $(1<<9), BX // ERMS
|
||||||
SETNE runtime·support_erms(SB)
|
SETNE runtime·support_erms(SB)
|
||||||
|
|
||||||
osavx:
|
osavx:
|
||||||
CMPB runtime·support_osxsave(SB), $1
|
CMPB runtime·support_osxsave(SB), $1
|
||||||
JNE noavx
|
JNE nocpuinfo
|
||||||
MOVL $0, CX
|
MOVL $0, CX
|
||||||
// For XGETBV, OSXSAVE bit is required and sufficient
|
// For XGETBV, OSXSAVE bit is required and sufficient
|
||||||
XGETBV
|
XGETBV
|
||||||
ANDL $6, AX
|
ANDL $6, AX
|
||||||
CMPL AX, $6 // Check for OS support of XMM and YMM registers.
|
CMPL AX, $6 // Check for OS support of XMM and YMM registers.
|
||||||
JE nocpuinfo
|
|
||||||
noavx:
|
|
||||||
MOVB $0, runtime·support_avx2(SB)
|
|
||||||
|
|
||||||
nocpuinfo:
|
nocpuinfo:
|
||||||
// if there is an _cgo_init, call it.
|
// if there is an _cgo_init, call it.
|
||||||
|
|
|
||||||
|
|
@ -67,11 +67,6 @@ eax7:
|
||||||
MOVL $0, CX
|
MOVL $0, CX
|
||||||
CPUID
|
CPUID
|
||||||
|
|
||||||
// If OS support for XMM and YMM is not present
|
|
||||||
// support_avx2 will be set back to false later.
|
|
||||||
TESTL $(1<<5), BX
|
|
||||||
SETNE runtime·support_avx2(SB)
|
|
||||||
|
|
||||||
TESTL $(1<<9), BX // ERMS
|
TESTL $(1<<9), BX // ERMS
|
||||||
SETNE runtime·support_erms(SB)
|
SETNE runtime·support_erms(SB)
|
||||||
|
|
||||||
|
|
@ -80,16 +75,13 @@ osavx:
|
||||||
// for XMM and YMM OS support.
|
// for XMM and YMM OS support.
|
||||||
#ifndef GOOS_nacl
|
#ifndef GOOS_nacl
|
||||||
CMPB runtime·support_osxsave(SB), $1
|
CMPB runtime·support_osxsave(SB), $1
|
||||||
JNE noavx
|
JNE nocpuinfo
|
||||||
MOVL $0, CX
|
MOVL $0, CX
|
||||||
// For XGETBV, OSXSAVE bit is required and sufficient
|
// For XGETBV, OSXSAVE bit is required and sufficient
|
||||||
XGETBV
|
XGETBV
|
||||||
ANDL $6, AX
|
ANDL $6, AX
|
||||||
CMPL AX, $6 // Check for OS support of XMM and YMM registers.
|
CMPL AX, $6 // Check for OS support of XMM and YMM registers.
|
||||||
JE nocpuinfo
|
|
||||||
#endif
|
#endif
|
||||||
noavx:
|
|
||||||
MOVB $0, runtime·support_avx2(SB)
|
|
||||||
|
|
||||||
nocpuinfo:
|
nocpuinfo:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,15 @@
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
import "internal/cpu"
|
import (
|
||||||
|
"internal/cpu"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Offsets into internal/cpu records for use in assembly.
|
||||||
|
const (
|
||||||
|
offsetX86HasAVX2 = unsafe.Offsetof(cpu.X86.HasAVX2)
|
||||||
|
)
|
||||||
|
|
||||||
var useAVXmemmove bool
|
var useAVXmemmove bool
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
// +build !plan9
|
// +build !plan9
|
||||||
|
|
||||||
|
#include "go_asm.h"
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
// NOTE: Windows externalthreadhandler expects memclr to preserve DX.
|
// NOTE: Windows externalthreadhandler expects memclr to preserve DX.
|
||||||
|
|
@ -36,7 +37,7 @@ tail:
|
||||||
JBE _65through128
|
JBE _65through128
|
||||||
CMPQ BX, $256
|
CMPQ BX, $256
|
||||||
JBE _129through256
|
JBE _129through256
|
||||||
CMPB runtime·support_avx2(SB), $1
|
CMPB internal∕cpu·X86+const_offsetX86HasAVX2(SB), $1
|
||||||
JE loop_preheader_avx2
|
JE loop_preheader_avx2
|
||||||
// TODO: use branch table and BSR to make this just a single dispatch
|
// TODO: use branch table and BSR to make this just a single dispatch
|
||||||
// TODO: for really big clears, use MOVNTDQ, even without AVX2.
|
// TODO: for really big clears, use MOVNTDQ, even without AVX2.
|
||||||
|
|
|
||||||
|
|
@ -779,7 +779,6 @@ var (
|
||||||
processorVersionInfo uint32
|
processorVersionInfo uint32
|
||||||
isIntel bool
|
isIntel bool
|
||||||
lfenceBeforeRdtsc bool
|
lfenceBeforeRdtsc bool
|
||||||
support_avx2 bool
|
|
||||||
support_erms bool
|
support_erms bool
|
||||||
support_osxsave bool
|
support_osxsave bool
|
||||||
support_popcnt bool
|
support_popcnt bool
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue