1
0
mirror of https://github.com/golang/go synced 2024-11-24 19:20:03 -07:00

[dev.ssa] cmd/compile/internal/ssa: eliminate phis during deadcode removal

While investigating the differences between 19710 (remove
tautological controls) and 12960 (bounds and nil propagation)
I observed that part of the wins of 19710 come from missed
opportunities for deadcode elimination due to phis.
See for example runtime.stackcacherelease. 19710 happens much
later than 12960 and has more chances to eliminate bounds.

Size of pkg/tool/linux_amd64/* excluding compile:

-this -12960 95882248
+this -12960 95880120
-this +12960 95581512
+this +12960 95555224

This change saves about 25k.

Change-Id: Id2f4e55fc92b71595842ce493c3ed527d424fe0e
Reviewed-on: https://go-review.googlesource.com/19728
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Alexandru Moșoi 2016-02-22 17:14:53 +01:00 committed by Alexandru Moșoi
parent c17b6b488c
commit 40f2b57e0b
2 changed files with 37 additions and 35 deletions

View File

@ -234,8 +234,7 @@ func (b *Block) removePred(p *Block) {
v.Args[i] = v.Args[n]
v.Args[n] = nil // aid GC
v.Args = v.Args[:n]
if n == 1 {
v.Op = OpCopy
phielimValue(v)
// Note: this is trickier than it looks. Replacing
// a Phi with a Copy can in general cause problems because
// Phi and Copy don't have exactly the same semantics.
@ -269,4 +268,3 @@ func (b *Block) removePred(p *Block) {
// graph can only happen in an unreachable cycle.
}
}
}

View File

@ -40,7 +40,11 @@ func phielimValue(v *Value) bool {
// are not v itself, then the phi must remain.
// Otherwise, we can replace it with a copy.
var w *Value
for _, x := range v.Args {
for i, x := range v.Args {
if b := v.Block.Preds[i]; b.Kind == BlockFirst && b.Succs[1] == v.Block {
// This branch is never taken so we can just eliminate it.
continue
}
if x == v {
continue
}