]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: simplify converted SSA form for 'if false'
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 2 Mar 2020 21:51:20 +0000 (13:51 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 3 Mar 2020 18:42:30 +0000 (18:42 +0000)
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 <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go

index f2a472bde6371a5b2db093f9c4646297262cbeee..34adeabae1fff699abb5e312eeed4b49367c2b00 100644 (file)
@@ -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() {