mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: cache CFG-dependent computations
We compute a lot of stuff based off the CFG: postorder traversal, dominators, dominator tree, loop nest. Multiple phases use this information and we end up recomputing some of it. Add a cache for this information so if the CFG hasn't changed, we can reuse the previous computation. Change-Id: I9b5b58af06830bd120afbee9cfab395a0a2f74b2 Reviewed-on: https://go-review.googlesource.com/29356 Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
2679282da4
commit
75ce89c20d
18 changed files with 83 additions and 59 deletions
|
|
@ -131,13 +131,13 @@ func cse(f *Func) {
|
|||
}
|
||||
}
|
||||
|
||||
// Dominator tree (f.sdom) is computed by the generic domtree pass.
|
||||
sdom := f.sdom()
|
||||
|
||||
// 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.
|
||||
rewrite := make([]*Value, f.NumValues())
|
||||
for _, e := range partition {
|
||||
sort.Sort(partitionByDom{e, f.sdom})
|
||||
sort.Sort(partitionByDom{e, sdom})
|
||||
for i := 0; i < len(e)-1; i++ {
|
||||
// e is sorted by domorder, so a maximal dominant element is first in the slice
|
||||
v := e[i]
|
||||
|
|
@ -152,7 +152,7 @@ func cse(f *Func) {
|
|||
if w == nil {
|
||||
continue
|
||||
}
|
||||
if f.sdom.isAncestorEq(v.Block, w.Block) {
|
||||
if sdom.isAncestorEq(v.Block, w.Block) {
|
||||
rewrite[w.ID] = v
|
||||
e[j] = nil
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue