From: Josh Bleecher Snyder Date: Mon, 2 Mar 2020 21:51:20 +0000 (-0800) Subject: cmd/compile: simplify converted SSA form for 'if false' X-Git-Tag: go1.15beta1~947 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7b0b6c2f7e9d925763a2e1d2ba10682019827a9b;p=gostls13.git cmd/compile: simplify converted SSA form for 'if false' The goal here is to make it easier for a human to examine the SSA when a function contains lots of dead code. No significant compiler metric or generated code differences. Change-Id: I81915fa4639bc8820cc9a5e45e526687d0d1f57a Reviewed-on: https://go-review.googlesource.com/c/go/+/221791 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index f2a472bde6..34adeabae1 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -1274,6 +1274,16 @@ func (s *state) stmt(n *Node) { s.assign(n.Left, r, deref, skip) case OIF: + if Isconst(n.Left, CTBOOL) { + s.stmtList(n.Left.Ninit) + if n.Left.Bool() { + s.stmtList(n.Nbody) + } else { + s.stmtList(n.Rlist) + } + break + } + bEnd := s.f.NewBlock(ssa.BlockPlain) var likely int8 if n.Likely() {