diff options
author | Keith Randall <khr@golang.org> | 2016-08-04 10:08:20 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2016-08-04 10:08:20 -0700 |
commit | d2286ea2843569c7d277587f3d3ef06ae4092b78 (patch) | |
tree | 0e2c7fa3abda784d6aa797bc8cbfbadbdcb0d693 /src/cmd/compile/internal/ssa/tighten.go | |
parent | 6a1153acb4aff2d481be1611862be0f9f5203e62 (diff) | |
parent | 50edddb7383a0e4aef990a085777f958c5d8a2b8 (diff) | |
download | go-d2286ea2843569c7d277587f3d3ef06ae4092b78.tar.gz go-d2286ea2843569c7d277587f3d3ef06ae4092b78.zip |
[dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Semi-regular merge from tip into dev.ssa.
Change-Id: Iadb60e594ef65a99c0e1404b14205fa67c32a9e9
Diffstat (limited to 'src/cmd/compile/internal/ssa/tighten.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/tighten.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/tighten.go b/src/cmd/compile/internal/ssa/tighten.go index b722f108e5..5be55ac858 100644 --- a/src/cmd/compile/internal/ssa/tighten.go +++ b/src/cmd/compile/internal/ssa/tighten.go @@ -92,3 +92,26 @@ func tighten(f *Func) { } } } + +// phiTighten moves constants closer to phi users. +// This pass avoids having lots of constants live for lots of the program. +// See issue 16407. +func phiTighten(f *Func) { + for _, b := range f.Blocks { + for _, v := range b.Values { + if v.Op != OpPhi { + continue + } + for i, a := range v.Args { + if !a.rematerializeable() { + continue // not a constant we can move around + } + if a.Block == b.Preds[i].b { + continue // already in the right place + } + // Make a copy of a, put in predecessor block. + v.SetArg(i, a.copyInto(b.Preds[i].b)) + } + } + } +} |