-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: improve code generation for math.Abs #13095
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
Comments
CL https://golang.org/cl/16444 mentions this issue. |
The compiler can do a fine job, and can also inline it. From Jeremy Jackins's observation and rsc's recommendation in thread: "Pure Go math.Abs outperforms assembly version" https://groups.google.com/forum/#!topic/golang-dev/nP5mWvwAXZo Updates #13095 Change-Id: I3066f8eaa327bb403173b29791cc8661d7c0532c Reviewed-on: https://go-review.googlesource.com/16444 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Mostly the problem is about getting rid of the stores. Step 1 would be an SSA rule that recognizes that a store followed by a load from the same address can short-circuit the store and use the store's argument directly instead of the load. Step 2 would be to recognize that stores to auto variables that are never read again can be dropped. Step 3 is to replace the and with two shifts. |
CL https://golang.org/cl/19482 mentions this issue. |
Fixed by https://golang.org/cl/19485. |
Turns out CL 19485 is not enough, see discussion on the CL. |
@randall77, not sure whether you're continuing your intrinsification crusade, but maybe the popular funcs at least in math are candidates. (Reminded after seeing @mundaym's https://go-review.googlesource.com/27827 and the TODO in https://golang.org/src/math/abs.go?s=278:305#L2:
|
I think I will continue intrinsification to sync/atomic, but probably stop there. It feels wrong to intrinsify something that's easily writeable in Go. And I still have hope for doing this more generically. |
Change https://golang.org/cl/58732 mentions this issue: |
Change https://golang.org/cl/63050 mentions this issue: |
Change https://golang.org/cl/63190 mentions this issue: |
From the thread,
"Pure Go math.Abs outperforms assembly version"
https://groups.google.com/forum/#!topic/golang-dev/nP5mWvwAXZo
It was noted that the code generation for
is not ideal:
@randall77 wrote:
This is bug about improving it.
The text was updated successfully, but these errors were encountered: