cmd/compile: add debugging flag for simd "midway" transformation

Change-Id: I2cb5f5aada2f40ee950e748c1c441749d80c91e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/788962
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/src/cmd/compile/internal/base/debug.go b/src/cmd/compile/internal/base/debug.go
index 0b5f9d2..a4cbe72 100644
--- a/src/cmd/compile/internal/base/debug.go
+++ b/src/cmd/compile/internal/base/debug.go
@@ -68,6 +68,7 @@
 	Panic                 int    `help:"show all compiler panics"`
 	Reshape               int    `help:"print information about expression reshaping"`
 	Shapify               int    `help:"print information about shaping recursive types"`
+	Simd                  int    `help:"print information about simd analysis and code transformation" concurrent:"ok"`
 	Slice                 int    `help:"print information about slice compilation"`
 	SoftFloat             int    `help:"force compiler to emit soft-float code" concurrent:"ok"`
 	StaticCopy            int    `help:"print information about missed static copies" concurrent:"ok"`
diff --git a/src/cmd/compile/internal/midway/analysis.go b/src/cmd/compile/internal/midway/analysis.go
index e424018..30b4288 100644
--- a/src/cmd/compile/internal/midway/analysis.go
+++ b/src/cmd/compile/internal/midway/analysis.go
@@ -5,6 +5,7 @@
 package midway
 
 import (
+	"cmd/compile/internal/base"
 	"cmd/compile/internal/syntax"
 	"cmd/compile/internal/types2"
 )
@@ -148,6 +149,9 @@
 	}
 
 	if isDep {
+		if base.Debug.Simd > 0 {
+			base.Warn("%v is simd-dependent", obj)
+		}
 		a.dependentObj[obj] = true
 	}
 	return isDep
diff --git a/src/cmd/compile/internal/midway/deepcopy.go b/src/cmd/compile/internal/midway/deepcopy.go
index 40f4158..ba00742 100644
--- a/src/cmd/compile/internal/midway/deepcopy.go
+++ b/src/cmd/compile/internal/midway/deepcopy.go
@@ -8,6 +8,7 @@
 	"fmt"
 	"strings"
 
+	"cmd/compile/internal/base"
 	"cmd/compile/internal/syntax"
 	"cmd/compile/internal/types2"
 )
@@ -75,6 +76,9 @@
 	if c.analyzer.dependentObj[obj] || isBaseSimdTypeObj(obj) {
 		newId := syntax.NewName(id.Pos(), id.Value+c.suffix)
 		// Object link will be handled manually in deepcopier Use/Def mapper
+		if base.Debug.Simd > 0 {
+			base.Warn("Rewriting name %s to %s", id.Value, newId.Value)
+		}
 		return newId
 	}
 	return nil
@@ -94,7 +98,7 @@
 	if isBaseSimdTypeObj(obj) {
 		// if it is a name, that means that this is in the simd package,
 		// and the name must be replaced with a selector referencing
-		// the architecture-dependent packages..
+		// the architecture-dependent packages.
 		name := id.Value
 		width := nameToElemBitWidth(name)
 		if width > 0 {
@@ -125,6 +129,9 @@
 	if c.analyzer.dependentObj[obj] {
 		newId := syntax.NewName(id.Pos(), id.Value+c.suffix)
 		// Object link will be handled manually in deepcopier Use/Def mapper
+		if base.Debug.Simd > 0 {
+			base.Warn("Rewriting name %s to %s", id.Value, newId.Value)
+		}
 		return newId
 	}
 	return nil