diff options
author | Keith Randall <khr@golang.org> | 2016-09-30 10:12:32 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2016-10-03 20:30:08 +0000 |
commit | 5a6e511c614a158cb58150fb62bfbc207a33922d (patch) | |
tree | 311639b9551d49020a3dde7138ac8e0a06794bf2 /src/cmd/compile/internal/ssa/block.go | |
parent | d0e92f61e5c5c59395d9b1a3b4f5c7b90dec5bc8 (diff) | |
download | go-5a6e511c614a158cb58150fb62bfbc207a33922d.tar.gz go-5a6e511c614a158cb58150fb62bfbc207a33922d.zip |
cmd/compile: Use Sreedhar+Gao phi building algorithm
Should be more asymptotically happy.
We process each variable in turn to find all the
locations where it needs a phi (the dominance frontier
of all of its definitions). Then we add all those phis.
This takes O(n * #variables), although hopefully much less.
Then we do a single tree walk to match all the
FwdRefs with the nearest definition or phi.
This takes O(n) time.
The one remaining inefficiency is that we might end up
introducing a bunch of dead phis in the first step.
A TODO is to introduce phis only where they might be
used by a read.
The old algorithm is still faster on small functions,
so there's a cutover size (currently 500 blocks).
This algorithm supercedes the David's sparse phi
placement algorithm for large functions.
Lowers compile time of example from #14934 from
~10 sec to ~4 sec.
Lowers compile time of example from #16361 from
~4.5 sec to ~3 sec.
Lowers #16407 from ~20 min to ~30 sec.
Update #14934
Update #16361
Fixes #16407
Change-Id: I1cff6364e1623c143190b6a924d7599e309db58f
Reviewed-on: https://go-review.googlesource.com/30163
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/block.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/block.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/block.go b/src/cmd/compile/internal/ssa/block.go index b5bedd3912..3ee27df5e7 100644 --- a/src/cmd/compile/internal/ssa/block.go +++ b/src/cmd/compile/internal/ssa/block.go @@ -89,6 +89,9 @@ type Edge struct { func (e Edge) Block() *Block { return e.b } +func (e Edge) Index() int { + return e.i +} // kind control successors // ------------------------------------------ |