]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.simd] cmd/compile: more support for cpufeatures
authorDavid Chase <drchase@google.com>
Thu, 9 Oct 2025 18:39:59 +0000 (14:39 -0400)
committerJunyang Shao <shaojunyang@google.com>
Mon, 13 Oct 2025 16:27:28 +0000 (09:27 -0700)
add hasFeature, also record maximum feature for a function

Change-Id: I68dd063aad1c1dc0ef5310a9f5d970c03dd31a0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/710695
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/ssa/block.go
src/cmd/compile/internal/ssa/cpufeatures.go
src/cmd/compile/internal/ssa/func.go

index f457e66f16e1a96533a93f84a45626e925fd0c3e..0ed90b5a7f15e8a53e593ea1350bd271d0abc764 100644 (file)
@@ -473,6 +473,10 @@ const (
        CPUsve2
 )
 
+func (f CPUfeatures) hasFeature(x CPUfeatures) bool {
+       return f&x == x
+}
+
 func (f CPUfeatures) String() string {
        if f == CPUNone {
                return "none"
index 77b1db552d2a85c1bb51143e5f6b1a6117dc8021..e668958fab5339896733cf6da2f49732083f644e 100644 (file)
@@ -201,6 +201,7 @@ func cpufeatures(f *Func) {
                }
 
                b.CPUfeatures = feat
+               f.maxCPUFeatures |= feat // not necessary to refine this estimate below
        }
 
        // If the flow graph is irreducible, things can still change on backedges.
index 0f895e501895363bb1eb4cec5926937c44bcf6e4..4368252da461cc088e322dfee592c813a5eca756 100644 (file)
@@ -41,6 +41,8 @@ type Func struct {
        ABISelf        *abi.ABIConfig // ABI for function being compiled
        ABIDefault     *abi.ABIConfig // ABI for rtcall and other no-parsed-signature/pragma functions.
 
+       maxCPUFeatures CPUfeatures // union of all the CPU features in all the blocks.
+
        scheduled   bool  // Values in Blocks are in final order
        laidout     bool  // Blocks are ordered
        NoSplit     bool  // true if function is marked as nosplit.  Used by schedule check pass.