From 1cbc5aa5290437e81859911cf8e022be2448cc09 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Tue, 15 Nov 2016 22:33:10 -0800 Subject: [PATCH] cmd/compile: insertVarPhis micro-optimization MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Algorithmic improvements here are hard. Lifting a lookup out of the loop helps a little, though. To compile the code in #17926: name old s/op new s/op delta Real 146 ± 3% 140 ± 4% -3.87% (p=0.002 n=10+10) User 143 ± 3% 139 ± 4% -3.08% (p=0.005 n=10+10) Sys 8.28 ±35% 8.08 ±28% ~ (p=0.684 n=10+10) Updates #17926. Change-Id: Ic255ac8b7b409c1a53791058818b7e2cf574abe3 Reviewed-on: https://go-review.googlesource.com/33305 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/cmd/compile/internal/gc/phi.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmd/compile/internal/gc/phi.go b/src/cmd/compile/internal/gc/phi.go index 540e144c38..b6b9ea940d 100644 --- a/src/cmd/compile/internal/gc/phi.go +++ b/src/cmd/compile/internal/gc/phi.go @@ -224,10 +224,11 @@ func (s *phiState) insertVarPhis(n int, var_ *Node, defs []*ssa.Block, typ ssa.T fmt.Printf(" processing %s\n", b) } + currentRootLevel := s.level[currentRoot.ID] for _, e := range b.Succs { c := e.Block() // TODO: if the variable is dead at c, skip it. - if s.level[c.ID] > s.level[currentRoot.ID] { + if s.level[c.ID] > currentRootLevel { // a D-edge, or an edge whose target is in currentRoot's subtree. continue } -- 2.50.0