From 7b0b6c2f7e9d925763a2e1d2ba10682019827a9b Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Mon, 2 Mar 2020 13:51:20 -0800 Subject: [PATCH] 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 --- src/cmd/compile/internal/gc/ssa.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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() { -- 2.50.0