]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use shared dom tree for cse, too
authorAlexandru Moșoi <mosoi@google.com>
Wed, 13 Apr 2016 08:58:38 +0000 (10:58 +0200)
committerAlexandru Moșoi <alexandru@mosoi.ro>
Wed, 13 Apr 2016 12:42:44 +0000 (12:42 +0000)
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>
src/cmd/compile/internal/ssa/compile.go
src/cmd/compile/internal/ssa/cse.go
src/cmd/compile/internal/ssa/cse_test.go

index f4f0d8cab2879e1174dcef4ab6ec3ba7262cbb77..a0b5ff71cf8c8890e218a324785a37d879031624 100644 (file)
@@ -233,8 +233,8 @@ var passes = [...]pass{
        {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: "opt deadcode", fn: deadcode, required: true}, // remove any blocks orphaned during opt
-       {name: "generic cse", fn: cse},
        {name: "generic domtree", fn: domTree},
+       {name: "generic cse", fn: cse},
        {name: "phiopt", fn: phiopt},
        {name: "nilcheckelim", fn: nilcheckelim},
        {name: "prove", fn: prove},
@@ -289,7 +289,8 @@ var passOrder = [...]constraint{
        {"opt", "nilcheckelim"},
        // tighten should happen before lowering to avoid splitting naturally paired instructions such as CMP/SET
        {"tighten", "lower"},
-       // nilcheckelim, prove and loopbce share idom.
+       // cse, nilcheckelim, prove and loopbce share idom.
+       {"generic domtree", "generic cse"},
        {"generic domtree", "nilcheckelim"},
        {"generic domtree", "prove"},
        {"generic domtree", "loopbce"},
index 9853ff06d040d256feab5fd47ea2d5357e0ff45a..c12d51e50c5300ac0a143c91781bdb713a9234b3 100644 (file)
@@ -131,9 +131,7 @@ func cse(f *Func) {
                }
        }
 
-       // Compute dominator tree
-       idom := dominators(f)
-       sdom := newSparseTree(f, idom)
+       // Dominator tree (f.sdom) is computed by the generic domtree pass.
 
        // 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.
@@ -143,7 +141,7 @@ func cse(f *Func) {
                        // Find a maximal dominant element in e
                        v := e[0]
                        for _, w := range e[1:] {
-                               if sdom.isAncestorEq(w.Block, v.Block) {
+                               if f.sdom.isAncestorEq(w.Block, v.Block) {
                                        v = w
                                }
                        }
@@ -153,7 +151,7 @@ func cse(f *Func) {
                                w := e[i]
                                if w == v {
                                        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
                                        e, e[i] = e[:len(e)-1], e[len(e)-1]
                                } else {
index 905939fc32199585e068c8e9e9430f2edcdb034a..d5be2b52ec4130720af1c2edca9f4460247967f6 100644 (file)
@@ -44,6 +44,7 @@ func TestCSEAuxPartitionBug(t *testing.T) {
                        Exit("rstore")))
 
        CheckFunc(fun.f)
+       domTree(fun.f)
        cse(fun.f)
        deadcode(fun.f)
        CheckFunc(fun.f)