From 7879e9193b39e6455ae03f2baace9c41f6393ee4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexandru=20Mo=C8=99oi?= Date: Thu, 21 Apr 2016 10:11:33 +0200 Subject: [PATCH] cmd/compile: reenable phielim during rewrite MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Remove the "optimization" that was causing the issue. For the following code the "optimization" was converting v to (OpCopy x) which is wrong because x doesn't dominate v. b1: y = ... First .. b3 b2: x = ... Goto b3 b3: v = phi x y ... use v ... That "optimization" is likely no longer needed because we now have a second opt pass with a dce in between which removes blocks of type First. For pkg/tools/linux_amd64/* the binary size drops from 82142886 to 82060034. Change-Id: I10428abbd8b32c5ca66fec3da2e6f3686dddbe31 Reviewed-on: https://go-review.googlesource.com/22312 Run-TryBot: Alexandru Moșoi TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/phielim.go | 6 +----- src/cmd/compile/internal/ssa/rewrite.go | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/ssa/phielim.go b/src/cmd/compile/internal/ssa/phielim.go index ce3b5a199a..77013c6481 100644 --- a/src/cmd/compile/internal/ssa/phielim.go +++ b/src/cmd/compile/internal/ssa/phielim.go @@ -40,11 +40,7 @@ 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 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 - } + for _, x := range v.Args { if x == v { continue } diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go index 9c625825b9..c2f8ceadaf 100644 --- a/src/cmd/compile/internal/ssa/rewrite.go +++ b/src/cmd/compile/internal/ssa/rewrite.go @@ -40,6 +40,8 @@ func applyRewrite(f *Func, rb func(*Block) bool, rv func(*Value, *Config) bool) } curb = nil for _, v := range b.Values { + change = phielimValue(v) || change + // Eliminate copy inputs. // If any copy input becomes unused, mark it // as invalid and discard its argument. Repeat -- 2.48.1