[dev.ssa] cmd/compile: implement OGETG

Change-Id: I7ecf62cf399c710b4a617803c43e83fce09b8a7d
Reviewed-on: https://go-review.googlesource.com/13585
Reviewed-by: Keith Randall <khr@golang.org>
diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go
index 6371ac2..e393054 100644
--- a/src/cmd/compile/internal/ssa/rewritegeneric.go
+++ b/src/cmd/compile/internal/ssa/rewritegeneric.go
@@ -782,6 +782,30 @@
 func rewriteBlockgeneric(b *Block) bool {
 	switch b.Kind {
 	case BlockIf:
+		// match: (If (IsNonNil (GetG)) yes no)
+		// cond:
+		// result: (Plain nil yes)
+		{
+			v := b.Control
+			if v.Op != OpIsNonNil {
+				goto end0f2bb0111a86be0436b44210dbd83a90
+			}
+			if v.Args[0].Op != OpGetG {
+				goto end0f2bb0111a86be0436b44210dbd83a90
+			}
+			yes := b.Succs[0]
+			no := b.Succs[1]
+			b.Func.removePredecessor(b, no)
+			b.Kind = BlockPlain
+			b.Control = nil
+			b.Succs = b.Succs[:1]
+			b.Succs[0] = yes
+			b.Likely = BranchUnknown
+			return true
+		}
+		goto end0f2bb0111a86be0436b44210dbd83a90
+	end0f2bb0111a86be0436b44210dbd83a90:
+		;
 		// match: (If (Not cond) yes no)
 		// cond:
 		// result: (If cond no yes)