From ba72ee0f308e1450fa18c4073b18275377671997 Mon Sep 17 00:00:00 2001 From: David Chase Date: Thu, 9 Oct 2025 14:39:59 -0400 Subject: [PATCH] [dev.simd] cmd/compile: more support for cpufeatures 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 LUCI-TryBot-Result: Go LUCI --- src/cmd/compile/internal/ssa/block.go | 4 ++++ src/cmd/compile/internal/ssa/cpufeatures.go | 1 + src/cmd/compile/internal/ssa/func.go | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/cmd/compile/internal/ssa/block.go b/src/cmd/compile/internal/ssa/block.go index f457e66f16..0ed90b5a7f 100644 --- a/src/cmd/compile/internal/ssa/block.go +++ b/src/cmd/compile/internal/ssa/block.go @@ -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" diff --git a/src/cmd/compile/internal/ssa/cpufeatures.go b/src/cmd/compile/internal/ssa/cpufeatures.go index 77b1db552d..e668958fab 100644 --- a/src/cmd/compile/internal/ssa/cpufeatures.go +++ b/src/cmd/compile/internal/ssa/cpufeatures.go @@ -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. diff --git a/src/cmd/compile/internal/ssa/func.go b/src/cmd/compile/internal/ssa/func.go index 0f895e5018..4368252da4 100644 --- a/src/cmd/compile/internal/ssa/func.go +++ b/src/cmd/compile/internal/ssa/func.go @@ -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. -- 2.52.0