Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: functions with constant declarations in them are never inlined #7655

Closed
cookieo9 opened this issue Mar 27, 2014 · 5 comments
Closed

Comments

@cookieo9
Copy link
Contributor

When a function, no matter how simple, contains and uses a const declaration it is not
inline-able: http://play.golang.org/p/gXJopk4eC-

The difference between the two functions is that one uses a variable, and the other a
const declaration, yet the former can be inlined, the latter is not. This can be seen
when compiling with "-gcflags -m".

Tested on darwin/amd64 at tip.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.4.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 2:

Labels changed: added release-go1.5, removed release-go1.4.

Status changed to Accepted.

@bradfitz bradfitz modified the milestone: Go1.5 Dec 16, 2014
@rsc rsc removed accepted labels Apr 14, 2015
@rsc rsc changed the title cmd/gc: functions with constant declarations in them are never inlined cmd/compile: functions with constant declarations in them are never inlined Jun 8, 2015
@rsc
Copy link
Contributor

rsc commented Jun 29, 2015

Too late for Go 1.5.

@rsc rsc modified the milestones: Go1.6Early, Go1.5 Jun 29, 2015
@josharian josharian self-assigned this Jun 29, 2015
@rsc rsc modified the milestones: Unplanned, Go1.6Early Nov 4, 2015
@gopherbot
Copy link

CL https://golang.org/cl/17171 mentions this issue.

rsc pushed a commit that referenced this issue Nov 26, 2015
Functions with switches (#13071) cannot be inlined.
Functions with consts (#7655) cannot be inlined.

benchmark                              old MB/s     new MB/s     speedup
BenchmarkEncodeDigitsSpeed1e4-4        10.25        10.20        1.00x
BenchmarkEncodeDigitsSpeed1e5-4        26.44        27.22        1.03x
BenchmarkEncodeDigitsSpeed1e6-4        32.28        33.51        1.04x
BenchmarkEncodeDigitsDefault1e4-4      8.61         8.74         1.02x
BenchmarkEncodeDigitsDefault1e5-4      7.03         6.98         0.99x
BenchmarkEncodeDigitsDefault1e6-4      6.47         6.46         1.00x
BenchmarkEncodeDigitsCompress1e4-4     8.62         8.73         1.01x
BenchmarkEncodeDigitsCompress1e5-4     7.01         6.98         1.00x
BenchmarkEncodeDigitsCompress1e6-4     6.43         6.53         1.02x
BenchmarkEncodeTwainSpeed1e4-4         9.67         10.16        1.05x
BenchmarkEncodeTwainSpeed1e5-4         26.46        26.94        1.02x
BenchmarkEncodeTwainSpeed1e6-4         33.19        34.02        1.03x
BenchmarkEncodeTwainDefault1e4-4       8.12         8.37         1.03x
BenchmarkEncodeTwainDefault1e5-4       8.22         8.21         1.00x
BenchmarkEncodeTwainDefault1e6-4       8.10         8.13         1.00x
BenchmarkEncodeTwainCompress1e4-4      8.24         8.39         1.02x
BenchmarkEncodeTwainCompress1e5-4      6.51         6.58         1.01x
BenchmarkEncodeTwainCompress1e6-4      6.16         6.13         1.00x

Change-Id: Ibafa5e3e2de0529853b5b3180e6fd6cb7090b76f
Reviewed-on: https://go-review.googlesource.com/17171
Reviewed-by: Russ Cox <rsc@golang.org>
@gopherbot
Copy link

CL https://golang.org/cl/20773 mentions this issue.

@golang golang locked and limited conversation to collaborators Mar 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants