]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: static composite literals are side-effect free
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 19 Apr 2016 19:26:28 +0000 (12:26 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 19 Apr 2016 20:56:00 +0000 (20:56 +0000)
This extends CL 22192.

This removes the remaining performance disparity
between non-SSA and SSA on the AppendInPlace benchmarks.

Going from non-SSA to SSA:

AppendInPlace/NoGrow/2Ptr-8  1.60µs ± 5%  1.53µs ± 5%  -4.04%  (p=0.000 n=15+14)
AppendInPlace/NoGrow/3Ptr-8  2.04µs ± 3%  1.96µs ± 2%  -3.90%  (p=0.000 n=13+14)
AppendInPlace/NoGrow/4Ptr-8  2.83µs ± 8%  2.62µs ± 4%  -7.39%  (p=0.000 n=13+15)

Previously these were 20% regressions.

Change-Id: Ie87810bffd598730658e07585f5e2ef979a12b8f
Reviewed-on: https://go-review.googlesource.com/22248
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/subr.go

index f6af11adbad4812edb89a46582fdb1277d08f67a..51a78317f28056a1b6d76fe99400fde4fbce5bf8 100644 (file)
@@ -1328,6 +1328,11 @@ func safeexpr(n *Node, init *Nodes) *Node {
                a.Right = r
                a = walkexpr(a, init)
                return a
+
+       case OSTRUCTLIT, OARRAYLIT:
+               if isStaticCompositeLiteral(n) {
+                       return n
+               }
        }
 
        // make a copy; must not be used as an lvalue