mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: use shared dom tree for cse, too
Missed this in the previous CL where the shared dom tree was introduced. Change-Id: If0bd85d4b4567d7e87814ed511603b1303ab3903 Reviewed-on: https://go-review.googlesource.com/21970 Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
61b7a9c57b
commit
e0611b1664
3 changed files with 7 additions and 7 deletions
|
|
@ -233,8 +233,8 @@ var passes = [...]pass{
|
||||||
{name: "opt", fn: opt, required: true}, // TODO: split required rules and optimizing rules
|
{name: "opt", fn: opt, required: true}, // TODO: split required rules and optimizing rules
|
||||||
{name: "zero arg cse", fn: zcse, required: true}, // required to merge OpSB values
|
{name: "zero arg cse", fn: zcse, required: true}, // required to merge OpSB values
|
||||||
{name: "opt deadcode", fn: deadcode, required: true}, // remove any blocks orphaned during opt
|
{name: "opt deadcode", fn: deadcode, required: true}, // remove any blocks orphaned during opt
|
||||||
{name: "generic cse", fn: cse},
|
|
||||||
{name: "generic domtree", fn: domTree},
|
{name: "generic domtree", fn: domTree},
|
||||||
|
{name: "generic cse", fn: cse},
|
||||||
{name: "phiopt", fn: phiopt},
|
{name: "phiopt", fn: phiopt},
|
||||||
{name: "nilcheckelim", fn: nilcheckelim},
|
{name: "nilcheckelim", fn: nilcheckelim},
|
||||||
{name: "prove", fn: prove},
|
{name: "prove", fn: prove},
|
||||||
|
|
@ -289,7 +289,8 @@ var passOrder = [...]constraint{
|
||||||
{"opt", "nilcheckelim"},
|
{"opt", "nilcheckelim"},
|
||||||
// tighten should happen before lowering to avoid splitting naturally paired instructions such as CMP/SET
|
// tighten should happen before lowering to avoid splitting naturally paired instructions such as CMP/SET
|
||||||
{"tighten", "lower"},
|
{"tighten", "lower"},
|
||||||
// nilcheckelim, prove and loopbce share idom.
|
// cse, nilcheckelim, prove and loopbce share idom.
|
||||||
|
{"generic domtree", "generic cse"},
|
||||||
{"generic domtree", "nilcheckelim"},
|
{"generic domtree", "nilcheckelim"},
|
||||||
{"generic domtree", "prove"},
|
{"generic domtree", "prove"},
|
||||||
{"generic domtree", "loopbce"},
|
{"generic domtree", "loopbce"},
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,7 @@ func cse(f *Func) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute dominator tree
|
// Dominator tree (f.sdom) is computed by the generic domtree pass.
|
||||||
idom := dominators(f)
|
|
||||||
sdom := newSparseTree(f, idom)
|
|
||||||
|
|
||||||
// Compute substitutions we would like to do. We substitute v for w
|
// Compute substitutions we would like to do. We substitute v for w
|
||||||
// if v and w are in the same equivalence class and v dominates w.
|
// if v and w are in the same equivalence class and v dominates w.
|
||||||
|
|
@ -143,7 +141,7 @@ func cse(f *Func) {
|
||||||
// Find a maximal dominant element in e
|
// Find a maximal dominant element in e
|
||||||
v := e[0]
|
v := e[0]
|
||||||
for _, w := range e[1:] {
|
for _, w := range e[1:] {
|
||||||
if sdom.isAncestorEq(w.Block, v.Block) {
|
if f.sdom.isAncestorEq(w.Block, v.Block) {
|
||||||
v = w
|
v = w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +151,7 @@ func cse(f *Func) {
|
||||||
w := e[i]
|
w := e[i]
|
||||||
if w == v {
|
if w == v {
|
||||||
e, e[i] = e[:len(e)-1], e[len(e)-1]
|
e, e[i] = e[:len(e)-1], e[len(e)-1]
|
||||||
} else if sdom.isAncestorEq(v.Block, w.Block) {
|
} else if f.sdom.isAncestorEq(v.Block, w.Block) {
|
||||||
rewrite[w.ID] = v
|
rewrite[w.ID] = v
|
||||||
e, e[i] = e[:len(e)-1], e[len(e)-1]
|
e, e[i] = e[:len(e)-1], e[len(e)-1]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ func TestCSEAuxPartitionBug(t *testing.T) {
|
||||||
Exit("rstore")))
|
Exit("rstore")))
|
||||||
|
|
||||||
CheckFunc(fun.f)
|
CheckFunc(fun.f)
|
||||||
|
domTree(fun.f)
|
||||||
cse(fun.f)
|
cse(fun.f)
|
||||||
deadcode(fun.f)
|
deadcode(fun.f)
|
||||||
CheckFunc(fun.f)
|
CheckFunc(fun.f)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue