Source file src/runtime/cpuflags_amd64.go
1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package runtime 6 7 import ( 8 "internal/cpu" 9 ) 10 11 var memmoveBits uint8 12 13 const ( 14 // avxSupported indicates that the CPU supports AVX instructions. 15 avxSupported = 1 << 0 16 17 // repmovsPreferred indicates that REP MOVSx instruction is more 18 // efficient on the CPU. 19 repmovsPreferred = 1 << 1 20 ) 21 22 func init() { 23 // Here we assume that on modern CPUs with both FSRM and ERMS features, 24 // copying data blocks of 2KB or larger using the REP MOVSB instruction 25 // will be more efficient to avoid having to keep up with CPU generations. 26 // Therefore, we may retain a BlockList mechanism to ensure that microarchitectures 27 // that do not fit this case may appear in the future. 28 // We enable it on Intel CPUs first, and we may support more platforms 29 // in the future. 30 isERMSNiceCPU := isIntel 31 useREPMOV := isERMSNiceCPU && cpu.X86.HasERMS && cpu.X86.HasFSRM 32 if cpu.X86.HasAVX { 33 memmoveBits |= avxSupported 34 } 35 if useREPMOV { 36 memmoveBits |= repmovsPreferred 37 } 38 } 39