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: emit variable byte-sized bit tests on amd64 #25156

Open
josharian opened this issue Apr 29, 2018 · 1 comment
Open

cmd/compile: emit variable byte-sized bit tests on amd64 #25156

josharian opened this issue Apr 29, 2018 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Milestone

Comments

@josharian
Copy link
Contributor

Conversation moved from CL 109716.

Consider this code from the runtime:

// Information from the compiler about the layout of stack frames.
type bitvector struct {
	n        int32 // # of bits
	bytedata *uint8
}

// ptrbit returns the i'th bit in bv.
func (bv *bitvector) ptrbit(i uintptr) uint8 {
	b := *(addb(bv.bytedata, i/8))
	return (b >> (i % 8)) & 1
}

ptrbit should generate a BTL instruction on amd64, but instead it generates RSH and AND. (Related work: CL 105037.) IIRC, we intentionally don't generate BTL instructions for constant-offset bit tests for bytes, since the equivalent TEST instruction is shorter or faster.

cc @rasky

@josharian josharian added this to the Unplanned milestone Apr 29, 2018
@rasky
Copy link
Member

rasky commented Apr 29, 2018

To clarify: I think ptrbit should generate a BTL instruction when ptrbit is used as part of a comparison: bv.ptrbit(i) == 1 or similar.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. Performance
Projects
None yet
Development

No branches or pull requests

3 participants