aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/likelyadjust.go
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2016-03-10 14:42:52 -0500
committerDavid Chase <drchase@google.com>2016-03-18 01:23:29 +0000
commit815c9a7f289d172c979261230260c0c5f0d1106e (patch)
tree9589d82c670f60c70d76d1dc2be648c31925136c /src/cmd/compile/internal/ssa/likelyadjust.go
parente4d489a85fd1825ddcc6c1ffda52fb9e75ad01b4 (diff)
downloadgo-815c9a7f289d172c979261230260c0c5f0d1106e.tar.gz
go-815c9a7f289d172c979261230260c0c5f0d1106e.zip
cmd/compile: use loop information in regalloc
This seems to help the problem reported in #14606; this change seems to produce about a 4% improvement (mostly for the 128-8192 shards). Fixes #14789. Change-Id: I1bd52c82d4ca81d9d5e9ab371fdfc860d7e8af50 Reviewed-on: https://go-review.googlesource.com/20660 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/likelyadjust.go')
-rw-r--r--src/cmd/compile/internal/ssa/likelyadjust.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/ssa/likelyadjust.go b/src/cmd/compile/internal/ssa/likelyadjust.go
index 4046958c7b..76251bdd14 100644
--- a/src/cmd/compile/internal/ssa/likelyadjust.go
+++ b/src/cmd/compile/internal/ssa/likelyadjust.go
@@ -13,8 +13,9 @@ type loop struct {
outer *loop // loop containing this loop
// Next two fields not currently used, but cheap to maintain,
// and aid in computation of inner-ness and list of blocks.
- nBlocks int32 // Number of blocks in this loop but not within inner loops
- isInner bool // True if never discovered to contain a loop
+ nBlocks int32 // Number of blocks in this loop but not within inner loops
+ isInner bool // True if never discovered to contain a loop
+ containsCall bool // if any block in this loop or any loop it contains is a BlockCall or BlockDefer
}
// outerinner records that outer contains inner
@@ -23,6 +24,21 @@ func (sdom sparseTree) outerinner(outer, inner *loop) {
if oldouter == nil || sdom.isAncestorEq(oldouter.header, outer.header) {
inner.outer = outer
outer.isInner = false
+ if inner.containsCall {
+ outer.setContainsCall()
+ }
+ }
+}
+
+func (l *loop) setContainsCall() {
+ for ; l != nil && !l.containsCall; l = l.outer {
+ l.containsCall = true
+ }
+
+}
+func (l *loop) checkContainsCall(bb *Block) {
+ if bb.Kind == BlockCall || bb.Kind == BlockDefer {
+ l.setContainsCall()
}
}
@@ -246,6 +262,7 @@ func loopnestfor(f *Func) *loopnest {
l = &loop{header: bb, isInner: true}
loops = append(loops, l)
b2l[bb.ID] = l
+ l.checkContainsCall(bb)
}
} else { // Perhaps a loop header is inherited.
// is there any loop containing our successor whose
@@ -274,6 +291,7 @@ func loopnestfor(f *Func) *loopnest {
if innermost != nil {
b2l[b.ID] = innermost
+ innermost.checkContainsCall(b)
innermost.nBlocks++
}
}