mirror of
https://github.com/golang/go
synced 2024-11-18 17:54:57 -07:00
cmd/compile: add more non-ID comparisons to schedule
These comparisons are fairly arbitrary, but they should be more stable in the face of other compiler changes than value ID. This reduces the number of value ID comparisons in schedule while running make.bash from 542,442 to 99,703. There are lots of changes to generated code from this change, but they appear to be overall neutral. It is possible to further reduce the number of comparisons in schedule; I have changes locally that reduce the number to about 25,000 during make.bash. However, the changes are increasingly complex and arcane, and reduce in much less code churn. Given that the goal is stability, that suggests that this is a reasonable place to stop, at least for now. Change-Id: Ie3a75f84fd3f3fdb102fcd0b29299950ea66b827 Reviewed-on: https://go-review.googlesource.com/c/go/+/229799 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
943a0d02d1
commit
80ced39396
@ -5,6 +5,7 @@
|
||||
package ssa
|
||||
|
||||
import (
|
||||
"cmd/compile/internal/types"
|
||||
"container/heap"
|
||||
"sort"
|
||||
)
|
||||
@ -62,6 +63,15 @@ func (h ValHeap) Less(i, j int) bool {
|
||||
if c := x.Uses - y.Uses; c != 0 {
|
||||
return c < 0 // smaller uses come later
|
||||
}
|
||||
// These comparisons are fairly arbitrary.
|
||||
// The goal here is stability in the face
|
||||
// of unrelated changes elsewhere in the compiler.
|
||||
if c := x.AuxInt - y.AuxInt; c != 0 {
|
||||
return c > 0
|
||||
}
|
||||
if cmp := x.Type.Compare(y.Type); cmp != types.CMPeq {
|
||||
return cmp == types.CMPgt
|
||||
}
|
||||
return x.ID > y.ID
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user