mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.simd] cmd/compile: inliner tweaks to favor simd-handling functions
this is partly to ensure that emulations get inlined Change-Id: I14f1a591081a4c39b61e48957a1474217ed0a399 Reviewed-on: https://go-review.googlesource.com/c/go/+/705975 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
This commit is contained in:
parent
fb1749a3fe
commit
48756abd3a
1 changed files with 21 additions and 2 deletions
|
|
@ -179,6 +179,16 @@ func CanInlineFuncs(funcs []*ir.Func, profile *pgoir.Profile) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func simdCreditMultiplier(fn *ir.Func) int32 {
|
||||||
|
for _, field := range fn.Type().RecvParamsResults() {
|
||||||
|
if field.Type.IsSIMD() {
|
||||||
|
return 3
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
// inlineBudget determines the max budget for function 'fn' prior to
|
// inlineBudget determines the max budget for function 'fn' prior to
|
||||||
// analyzing the hairiness of the body of 'fn'. We pass in the pgo
|
// analyzing the hairiness of the body of 'fn'. We pass in the pgo
|
||||||
// profile if available (which can change the budget), also a
|
// profile if available (which can change the budget), also a
|
||||||
|
|
@ -186,9 +196,14 @@ func CanInlineFuncs(funcs []*ir.Func, profile *pgoir.Profile) {
|
||||||
// possibility that a call to the function might have its score
|
// possibility that a call to the function might have its score
|
||||||
// adjusted downwards. If 'verbose' is set, then print a remark where
|
// adjusted downwards. If 'verbose' is set, then print a remark where
|
||||||
// we boost the budget due to PGO.
|
// we boost the budget due to PGO.
|
||||||
|
// Note that inlineCostOk has the final say on whether an inline will
|
||||||
|
// happen; changes here merely make inlines possible.
|
||||||
func inlineBudget(fn *ir.Func, profile *pgoir.Profile, relaxed bool, verbose bool) int32 {
|
func inlineBudget(fn *ir.Func, profile *pgoir.Profile, relaxed bool, verbose bool) int32 {
|
||||||
// Update the budget for profile-guided inlining.
|
// Update the budget for profile-guided inlining.
|
||||||
budget := int32(inlineMaxBudget)
|
budget := int32(inlineMaxBudget)
|
||||||
|
|
||||||
|
budget *= simdCreditMultiplier(fn)
|
||||||
|
|
||||||
if IsPgoHotFunc(fn, profile) {
|
if IsPgoHotFunc(fn, profile) {
|
||||||
budget = inlineHotMaxBudget
|
budget = inlineHotMaxBudget
|
||||||
if verbose {
|
if verbose {
|
||||||
|
|
@ -420,8 +435,8 @@ type hairyVisitor struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isDebugFn(fn *ir.Func) bool {
|
func isDebugFn(fn *ir.Func) bool {
|
||||||
// if n := fn.Nname; n != nil && n.Sym().Pkg.Path == "0" {
|
// if n := fn.Nname; n != nil {
|
||||||
// if n.Sym().Name == "BroadcastInt64x4" {
|
// if n.Sym().Name == "Int32x8.Transpose8" && n.Sym().Pkg.Path == "simd" {
|
||||||
// fmt.Printf("isDebugFn '%s' DOT '%s'\n", n.Sym().Pkg.Path, n.Sym().Name)
|
// fmt.Printf("isDebugFn '%s' DOT '%s'\n", n.Sym().Pkg.Path, n.Sym().Name)
|
||||||
// return true
|
// return true
|
||||||
// }
|
// }
|
||||||
|
|
@ -944,6 +959,8 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller, closureCal
|
||||||
maxCost = inlineBigFunctionMaxCost
|
maxCost = inlineBigFunctionMaxCost
|
||||||
}
|
}
|
||||||
|
|
||||||
|
simdMaxCost := simdCreditMultiplier(callee) * maxCost
|
||||||
|
|
||||||
if callee.ClosureParent != nil {
|
if callee.ClosureParent != nil {
|
||||||
maxCost *= 2 // favor inlining closures
|
maxCost *= 2 // favor inlining closures
|
||||||
if closureCalledOnce { // really favor inlining the one call to this closure
|
if closureCalledOnce { // really favor inlining the one call to this closure
|
||||||
|
|
@ -951,6 +968,8 @@ func inlineCostOK(n *ir.CallExpr, caller, callee *ir.Func, bigCaller, closureCal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxCost = max(maxCost, simdMaxCost)
|
||||||
|
|
||||||
metric := callee.Inl.Cost
|
metric := callee.Inl.Cost
|
||||||
if inlheur.Enabled() {
|
if inlheur.Enabled() {
|
||||||
score, ok := inlheur.GetCallSiteScore(caller, n)
|
score, ok := inlheur.GetCallSiteScore(caller, n)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue