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/internal/obj/arm: optimize type promotion #20653

Closed
benshi001 opened this issue Jun 13, 2017 · 5 comments
Closed

cmd/internal/obj/arm: optimize type promotion #20653

benshi001 opened this issue Jun 13, 2017 · 5 comments

Comments

@benshi001
Copy link
Member

Currently
var a int32
var b int8
a = int32(b) is built to MOVBS, which actually is
tmp = SLL b, 24
a = SRA tmp, 24

That is quite inefficient.

I suggest use single instruction SXTB which was introduced in ARMv6.
"Signed Extend Byte extracts an 8-bit value from a register, sign-extends it to 32 bits, and writes the result to the destination register."

So do int16->int32(SXTH), uint8->uint32(UXTB), uint16->uint32(UXTH)

It can be done in go1.10 and assigned to me.

@ALTree ALTree added this to the Go1.10 milestone Jun 13, 2017
@bradfitz
Copy link
Contributor

/cc @randall77

@randall77
Copy link
Contributor

Sounds fine to me. The only tricky part would be conditioning it for GOARM>=6.

@benshi001
Copy link
Member Author

benshi001 commented Aug 17, 2017

As Cherry @cherrymui suggeusts in https://go-review.googlesource.com/c/53690, more work is needed to introduce XTB/XTBU/XTH/XTHU to golang. Adding a new field in []optab for selecting different instructions for different GOARM version is a good way.

@benshi001
Copy link
Member Author

benshi001 commented Sep 22, 2017

@cherrymui
Cherry, I do not think XTB/XTBU/XTH/XTHU can be attributed to MOVB/MOVBU/MOVH/MOVHU,

since there are more complex forms, such as

XTH Rd, Rm, ROR #8

which means signed extension of Rm(23:8) to Rd.

@gopherbot
Copy link

Change https://golang.org/cl/71992 mentions this issue: cmd/compile: optimization with more efficient ARMv6 instructions

@golang golang locked and limited conversation to collaborators Oct 26, 2018
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

5 participants