• Keith Randall's avatar
    cmd/compile: implement comparisons directly with memory · 4b00d3f4
    Keith Randall authored
    Allow the compiler to generate code like CMPQ 16(AX), $7
    
    It's tricky because it's difficult to spill such a comparison during
    flagalloc, because the same memory state might not be available at
    the restore locations.
    
    Solve this problem by decomposing the compare+load back into its parts
    if it needs to be spilled.
    
    The big win is that the write barrier test goes from:
    
    MOVL	runtime.writeBarrier(SB), CX
    TESTL	CX, CX
    JNE	60
    
    to
    
    CMPL	runtime.writeBarrier(SB), $0
    JNE	59
    
    It's one instruction and one byte smaller.
    
    Fixes #19485
    Fixes #15245
    Update #22460
    
    Binaries are about 0.15% smaller.
    
    Change-Id: I4fd8d1111b6b9924d52f9a0901ca1b2e5cce0836
    Reviewed-on: https://go-review.googlesource.com/86035Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
    Reviewed-by: 's avatarIlya Tocar <ilya.tocar@intel.com>
    4b00d3f4
func.go 18.7 KB