Skip to content

cmd/compile: fold offsets into memory ops #23325

@randall77

Description

@randall77
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions