cmd/compile: avoid temporary in race mode with slice and append

Currently when the race detector is enabled, orderexpr always creates
a temporary for slice and append operations. This used to be necessary
because the race detector had a different code path for slice
assignment that required this temporary. Unfortunately, creating this
temporary inhibits the optimization that eliminates write barriers
when a slice is assigned only to change its length or cap. For most
code, this is bad for performance, and in go:nowritebarrier functions
in the runtime, this can mean the difference between compiling and not
compiling.

Now the race detector uses the regular slice assignment code, so
creating this temporary is no longer necessary.

Change-Id: I296042e1edc571b77c407f709c2ff9091c4aa795
Reviewed-on: https://go-review.googlesource.com/10456
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/src/cmd/compile/internal/gc/order.go b/src/cmd/compile/internal/gc/order.go
index 8b99ed0..ee0ec52 100644
--- a/src/cmd/compile/internal/gc/order.go
+++ b/src/cmd/compile/internal/gc/order.go
@@ -1090,7 +1090,7 @@
 
 	case OAPPEND:
 		ordercallargs(&n.List, order)
-		if lhs == nil || flag_race != 0 || lhs.Op != ONAME && !samesafeexpr(lhs, n.List.N) {
+		if lhs == nil || lhs.Op != ONAME && !samesafeexpr(lhs, n.List.N) {
 			n = ordercopyexpr(n, n.Type, order, 0)
 		}
 
@@ -1100,7 +1100,7 @@
 		n.Right.Left = ordercheapexpr(n.Right.Left, order)
 		orderexpr(&n.Right.Right, order, nil)
 		n.Right.Right = ordercheapexpr(n.Right.Right, order)
-		if lhs == nil || flag_race != 0 || lhs.Op != ONAME && !samesafeexpr(lhs, n.Left) {
+		if lhs == nil || lhs.Op != ONAME && !samesafeexpr(lhs, n.Left) {
 			n = ordercopyexpr(n, n.Type, order, 0)
 		}
 
@@ -1112,7 +1112,7 @@
 		n.Right.Right.Left = ordercheapexpr(n.Right.Right.Left, order)
 		orderexpr(&n.Right.Right.Right, order, nil)
 		n.Right.Right.Right = ordercheapexpr(n.Right.Right.Right, order)
-		if lhs == nil || flag_race != 0 || lhs.Op != ONAME && !samesafeexpr(lhs, n.Left) {
+		if lhs == nil || lhs.Op != ONAME && !samesafeexpr(lhs, n.Left) {
 			n = ordercopyexpr(n, n.Type, order, 0)
 		}