Commit 55ab07c2 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

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/22248Reviewed-by: 's avatarKeith Randall <khr@golang.org>
parent 3c6e60c0
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment