Skip to content

cmd/compile: add memory operand ADC and SBB to AMD64.rules #80400

Description

@Jorropo

Go version

go version go1.27-devel_a129840779 Mon Jul 13 14:06:37 2026 -0700 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v3'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN='/home/hugo/go/bin'
GOCACHE='/tmp/go-build/'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/hugo/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build784687367=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/hugo/k/go/src/go.mod'
GOMODCACHE='/home/hugo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPACKAGESDRIVER=''
GOPATH='/home/hugo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/hugo/k/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/hugo/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/hugo/k/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.27-devel_a129840779 Mon Jul 13 14:06:37 2026 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Compile:

package carry

import "math/bits"

func AddUseCarry(a, b [2]uint64, s uint64) uint64 {
	_, c := bits.Add64(a[0], b[0], 0)
	_, c2 := bits.Add64(a[1], b[1], c)
	return s + c2 // carry consumed by a plain add
}

What did you see happen?

TEXT command-line-arguments.AddUseCarry(SB), ABIInternal
    MOVQ command-line-arguments.a(SP), CX
    MOVQ command-line-arguments.b+16(SP), DX
    MOVQ command-line-arguments.a+8(SP), BX
    MOVQ command-line-arguments.b+24(SP), SI
    ADDQ CX, DX
    ADCQ SI, BX
    ADCQ $0, AX
    RET

What did you expect to see?

TEXT command-line-arguments.AddUseCarry(SB), ABIInternal
    MOVQ command-line-arguments.b+16(SP), DX
    MOVQ command-line-arguments.a+8(SP), BX
    ADDQ command-line-arguments.a(SP), DX
    ADCQ command-line-arguments.b+24(SP), BX
    ADCQ $0, AX
    RET

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.help wanted

    Type

    No type

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions