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: fold offsets into memory ops #23325

Closed
randall77 opened this issue Jan 3, 2018 · 4 comments
Closed

cmd/compile: fold offsets into memory ops #23325

randall77 opened this issue Jan 3, 2018 · 4 comments

Comments

@randall77
Copy link
Contributor

func f(x, y int) bool {
    return x < y
}

generates the assembly:

	0x0000 00000 (tmp5.go:3)	MOVQ	"".x+8(SP), AX
	0x0005 00005 (tmp5.go:3)	MOVQ	"".y+16(SP), CX
	0x000a 00010 (tmp5.go:4)	CMPQ	AX, CX
	0x000d 00013 (tmp5.go:4)	LEAQ	"".~r2+24(SP), AX
	0x0012 00018 (tmp5.go:4)	SETLT	(AX)

We should fold the LEAQ into the SETLT. We do so in many other cases, the SETXX cases were missed. We should audit to make sure that all ops for which we can fold address computations into, we do so.

@randall77 randall77 added this to the Go1.11 milestone Jan 3, 2018
@randall77 randall77 self-assigned this Jan 3, 2018
@randall77
Copy link
Contributor Author

Need to do (for amd64):

{ADD,SUB,MUL}[SD]mem
ADD[LQ]constmem
{ADD,SUB,AND,OR,XOR}[LQ]mem
SET{L,LE,G,GE,EQ,NE,A,AE,B,BE}mem

For each, fold an LEAQ or an ADDQ in the pointer slot into the instruction itself. Example:

(SETLmem [off1] {sym1} (LEAQ [off2] {sym2} ptr) x mem) && is32Bit(off1+off2) && canMergeSym(sym1, sym2) ->
	(SETLmem  [off1+off2] {mergeSym(sym1,sym2)} ptr x mem)
(SETLmem  [off1] {sym} (ADDQconst [off2] ptr) x mem) && is32Bit(off1+off2) -> (SETLmem  [off1+off2] {sym} ptr x mem)

@gopherbot
Copy link

Change https://golang.org/cl/86055 mentions this issue: cmd/compile: fold LEAQ and ADDQ into memory ops

@rasky
Copy link
Member

rasky commented Mar 1, 2018

SET*mem was done in 0cacc4d.

@gopherbot
Copy link

Change https://golang.org/cl/98035 mentions this issue: cmd/compile: fold offsets into memory ops

@golang golang locked and limited conversation to collaborators Mar 4, 2019
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

3 participants