mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.ssa] cmd/compile: fix -N build
The OpSB hack didn't quite work. We need to really CSE these ops to make regalloc happy. Change-Id: I9f4d7bfb0929407c84ee60c9e25ff0c0fbea84af Reviewed-on: https://go-review.googlesource.com/19083 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
056c09bb88
commit
8a961aee28
3 changed files with 29 additions and 7 deletions
|
|
@ -10,6 +10,34 @@ import "sort"
|
|||
// Values are just relinked, nothing is deleted. A subsequent deadcode
|
||||
// pass is required to actually remove duplicate expressions.
|
||||
func cse(f *Func) {
|
||||
if !f.Config.optimize {
|
||||
// Don't do CSE in this case. But we need to do
|
||||
// just a little bit, to combine multiple OpSB ops.
|
||||
// Regalloc gets very confused otherwise.
|
||||
var sb *Value
|
||||
outer:
|
||||
for _, b := range f.Blocks {
|
||||
for _, v := range b.Values {
|
||||
if v.Op == OpSB {
|
||||
sb = v
|
||||
break outer
|
||||
}
|
||||
}
|
||||
}
|
||||
if sb == nil {
|
||||
return
|
||||
}
|
||||
for _, b := range f.Blocks {
|
||||
for _, v := range b.Values {
|
||||
for i, a := range v.Args {
|
||||
if a.Op == OpSB {
|
||||
v.Args[i] = sb
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
// Two values are equivalent if they satisfy the following definition:
|
||||
// equivalent(v, w):
|
||||
// v.op == w.op
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue