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

proposal: return destination register from build functions #194

Open
dominikh opened this issue Jun 27, 2021 · 1 comment
Open

proposal: return destination register from build functions #194

dominikh opened this issue Jun 27, 2021 · 1 comment
Labels
proposal Ideas for discussion

Comments

@dominikh
Copy link

I propose that the functions in package build return the destination register, where it makes sense. This would be especially useful in the context of AVX/VEX encoding and the 3 argument form (with the destination register separate from the operands) and would allow writing code like this:

v1 := VMOVDQU(m1, YMM())
v2 := VMOVDQU(m2, YMM())
res := VPSUBB(v1, v2, YMM())

or even like this, if the loaded values don't need to be used again

res := VPSUBB(
  VMOVDQU(m1, YMM()), 
  VMOVDQU(m2, YMM()),
  YMM())

instead of

v1 := YMM()
v2 := YMM()
v3 := YMM()
VMOVDQU(m1, v1)
VMOVDQU(m2, v2)
VPSUBB(v1, v2, v3)

or the manually optimized version, which isn't necessary due to avo's register allocator, but still results in shorter Go code currently:

v1 := YMM()
v2 := YMM()
VMOVDQU(m1, v1)
VMOVDQU(m2, v2)
VPSUBB(v1, v2, v1)

There is some precedent for this, namely the Load function, which already returns the destination register.

@mmcloughlin mmcloughlin added the proposal Ideas for discussion label Jun 29, 2021
@mmcloughlin
Copy link
Owner

Thanks for the proposal! I'd need to think about it a bit more, but my initial reaction is that this could a be really nice addition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Ideas for discussion
Projects
None yet
Development

No branches or pull requests

2 participants