Commit f4e37c8e authored by Keith Randall's avatar Keith Randall

cmd/compile: use standard dom tree in nilcheckelim

No need to build a bespoke dom tree here when we might
have one cached already.  The allocations for the dom tree
were also more expensive than they needed to be.

Fixes #12021

Change-Id: I6a967880aee03660ad6fc293f8fc783779cae11d
Reviewed-on: https://go-review.googlesource.com/30671
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 433be563
...@@ -10,15 +10,7 @@ func nilcheckelim(f *Func) { ...@@ -10,15 +10,7 @@ func nilcheckelim(f *Func) {
// A nil check is redundant if the same nil check was successful in a // A nil check is redundant if the same nil check was successful in a
// dominating block. The efficacy of this pass depends heavily on the // dominating block. The efficacy of this pass depends heavily on the
// efficacy of the cse pass. // efficacy of the cse pass.
idom := f.idom() sdom := f.sdom()
domTree := make([][]*Block, f.NumBlocks())
// Create a block ID -> [dominees] mapping
for _, b := range f.Blocks {
if dom := idom[b.ID]; dom != nil {
domTree[dom.ID] = append(domTree[dom.ID], b)
}
}
// TODO: Eliminate more nil checks. // TODO: Eliminate more nil checks.
// We can recursively remove any chain of fixed offset calculations, // We can recursively remove any chain of fixed offset calculations,
...@@ -128,7 +120,7 @@ func nilcheckelim(f *Func) { ...@@ -128,7 +120,7 @@ func nilcheckelim(f *Func) {
b.Values = b.Values[:i] b.Values = b.Values[:i]
// Add all dominated blocks to the work list. // Add all dominated blocks to the work list.
for _, w := range domTree[node.block.ID] { for w := sdom[node.block.ID].child; w != nil; w = sdom[w.ID].sibling {
work = append(work, bp{op: Work, block: w}) work = append(work, bp{op: Work, block: w})
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment