-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: using r0 more efficiently on ppc64x with SSA #17109
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
I think this is a job for PPC patterns. I'll make time today or tomorrow to do a few for educational+optimizational purposes; the zero ones ought to be easy. Do you know about "GOSSAFUNC=foo" and then viewing ssa.html? I'll try to write up a guide; that seems like a high-leverage/priority task. |
I've tried to use GOSSAFUNC but it seems to not always work as I expect so some documentation would help. Sometimes I just generate a small testcase and use a golang that dumps out everything. |
I've been working on a guide today. There have been detours and digressions. |
CL https://golang.org/cl/29380 mentions this issue. |
Abandoned earlier efforts to expose zero register, but left it in numbering to decrease squirrelyness of register allocator. ISELrelOp used in code generation of bool := x relOp y. Some patterns added to better elide zero case and some sign extension. Updates: #17109 Change-Id: Ida7839f0023ca8f0ffddc0545f0ac269e65b05d9 Reviewed-on: https://go-review.googlesource.com/29380 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
@dr2chase Does your commit fix this issue? |
It's about half-fixed. There's some ugly code remaining, I will have a look at getting that out. It should be susceptible to the usual pattern-matching. |
CL https://golang.org/cl/30455 mentions this issue. |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +9fcbde7 Wed Sep 14 10:07:17 2016 -0500 linux/ppc64le
What operating system and processor architecture are you using (
go env
)?Ubuntu 16.04 ppc64le
What did you do?
Built the test from the math package and looked at objdump to inspect generated code now that we have SSA for ppc64le.
go test -c
objdump -D math.test
According to the golang ABI for ppc64le, r0 is dedicated and should always contain the value zero. Here are some examples where better code could be generated by taking advantage of that fact.
What did you expect to see?
Efficient use of r0
What did you see instead?
The potential for improvement in the following cases:
In main.matchString:
1105c: b4 07 04 7c extsw r4,r0
11060: 00 18 04 7c cmpw r4,r3
No need to do extsw or move it to another register. Should be able to just do cmpw r0,r3.
In runtime.interhash:
11844: b4 07 05 7c extsw r5,r0
11848: 3e 06 a5 54 clrlwi r5,r5,24
1184c: 00 20 05 7c cmpw r5,r4
Another example of unnecessary extsw with use of an extra register with an extra clrlwi as well.
In runtime.memequal8:
11b74: b4 07 04 7c extsw r4,r0
11b78: 30 00 81 98 stb r4,48(r1)
This could just be a stb r0,48(r1)
In runtime.c64hash:
1173c: 14 02 83 7c add r4,r3,r0
11740: 20 00 81 f8 std r4,32(r1)
The add r4,r3,r0 is just moving the register? But this could just be std r3,32(r1).
The text was updated successfully, but these errors were encountered: