aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/likelyadjust.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2017-03-18 11:16:30 -0700
committerKeith Randall <khr@golang.org>2017-03-23 15:53:04 +0000
commit86dc86b4f948e16001903879162e9cf8da8f0537 (patch)
treefd31c4246b4f7ba8711f4384a282103a9da1ac3f /src/cmd/compile/internal/ssa/likelyadjust.go
parentd0ff9ece2b36bd4470b4388602a757d50c4c3607 (diff)
downloadgo-86dc86b4f948e16001903879162e9cf8da8f0537.tar.gz
go-86dc86b4f948e16001903879162e9cf8da8f0537.zip
cmd/compile: don't merge load+op if other op arg is still live
We want to merge a load and op into a single instruction l = LOAD ptr mem y = OP x l into y = OPload x ptr mem However, all of our OPload instructions require that y uses the same register as x. If x is needed past this instruction, then we must copy x somewhere else, losing the whole benefit of merging the instructions in the first place. Disable this optimization if x is live past the OP. Also disable this optimization if the OP is in a deeper loop than the load. Update #19595 Change-Id: I87f596aad7e91c9127bfb4705cbae47106e1e77a Reviewed-on: https://go-review.googlesource.com/38337 Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/likelyadjust.go')
-rw-r--r--src/cmd/compile/internal/ssa/likelyadjust.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/likelyadjust.go b/src/cmd/compile/internal/ssa/likelyadjust.go
index 8a2fe1bbd2..72f0ae9c48 100644
--- a/src/cmd/compile/internal/ssa/likelyadjust.go
+++ b/src/cmd/compile/internal/ssa/likelyadjust.go
@@ -443,6 +443,14 @@ func (ln *loopnest) findExits() {
ln.initializedExits = true
}
+// depth returns the loop nesting level of block b.
+func (ln *loopnest) depth(b ID) int16 {
+ if l := ln.b2l[b]; l != nil {
+ return l.depth
+ }
+ return 0
+}
+
// recordIfExit checks sl (the loop containing b) to see if it
// is outside of loop l, and if so, records b as an exit block
// from l and returns true.