Skip to content

cmd/compile: using r0 more efficiently on ppc64x with SSA #17109

@laboger

Description

@laboger

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions