From: Josh Bleecher Snyder Date: Tue, 19 Apr 2016 19:26:28 +0000 (-0700) Subject: cmd/compile: static composite literals are side-effect free X-Git-Tag: go1.7beta1~603 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=55ab07c224a358cabe795fb1e52a627194d7daee;p=gostls13.git cmd/compile: static composite literals are side-effect free 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 --- diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go index f6af11adba..51a78317f2 100644 --- a/src/cmd/compile/internal/gc/subr.go +++ b/src/cmd/compile/internal/gc/subr.go @@ -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