Skip to content

cmd/compile: ADCQ and SBBQ rules no longer eat InvertFlags leading to ICE sometimes #79887

Closed

Description

@Jorropo

Go version

go version go1.27-devel_35e6f583ff Fri Jun 5 19:04:53 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-build1366802342=/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_35e6f583ff Fri Jun 5 19:04:53 2026 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Run:

package main

import "math/bits"

//go:noinline
func f(p, q, x, y uint64) uint64 {
	c := uint64(0)
	if p < q {
		c = 1
	}
	s, _ := bits.Sub64(x, y, c)
	return s
}

func main() {
	got := f(1, 2, 10, 3)
	println(got)
	if got != 6 {
		panic("wrong result")
	}
}

Or run:

package main

import "math/bits"

//go:noinline
func f(p, q, x, y uint64) uint64 {
	c := uint64(0)
	if p < q {
		c = 1
	}
	s, _ := bits.Add64(x, y, c)
	return s
}

func main() {
	got := f(1, 2, 10, 20)
	println(got)
	if got != 31 {
		panic("wrong result")
	}
}

What did you see happen?

# command-line-arguments
/tmp/a.go:8:7: internal compiler error: 'f': InvertFlags should never make it to codegen v17 = InvertFlags <flags> v16

goroutine 11 [running]:
runtime/debug.Stack()
	/home/hugo/k/go/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0x48e86db8?, 0x3b1f?}, {0x3b1f489d8900, 0x34}, {0x3b1f489ec640, 0x2, 0x2})
	/home/hugo/k/go/src/cmd/compile/internal/base/print.go:232 +0x18b
cmd/compile/internal/base.Fatalf(...)
	/home/hugo/k/go/src/cmd/compile/internal/base/print.go:197
cmd/compile/internal/ssagen.(*ssafn).Fatalf(0x8?, {0x1993950?, 0x0?}, {0x1096406, 0x2e}, {0x3b1f489f2c10, 0x1, 0x3b1f489f2c10?})
	/home/hugo/k/go/src/cmd/compile/internal/ssagen/ssa.go:8017 +0x171
cmd/compile/internal/ssa.(*Value).Fatalf(0x3b1f4857c8e0?, {0x1096406?, 0x0?}, {0x3b1f489f2c10?, 0x1a4f9a8?, 0x0?})
	/home/hugo/k/go/src/cmd/compile/internal/ssa/value.go:478 +0x52
cmd/compile/internal/amd64.ssaGenValue(0x3b1f489f4d20, 0x3b1f48a4e520)
	/home/hugo/k/go/src/cmd/compile/internal/amd64/ssa.go:1592 +0x3ca7
cmd/compile/internal/ssagen.genssa(0x3b1f486e81c0, 0x3b1f489e1500)
	/home/hugo/k/go/src/cmd/compile/internal/ssagen/ssa.go:7152 +0x1dff
cmd/compile/internal/ssagen.Compile(0x3b1f48944640, 0x1, 0xf72498?)
	/home/hugo/k/go/src/cmd/compile/internal/ssagen/pgen.go:314 +0x4c5
cmd/compile/internal/gc.compileFunctions.func2()
	/home/hugo/k/go/src/cmd/compile/internal/gc/compile.go:177 +0x85
created by cmd/compile/internal/gc.compileFunctions in goroutine 1
	/home/hugo/k/go/src/cmd/compile/internal/gc/compile.go:163 +0xdc

What did you expect to see?

Nothing

Activity

  1. self-assigned this
    on Jun 7, 2026
  2. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Jun 7, 2026
  3. gopherbot commented on Jun 7, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/787741 mentions this issue: cmd/compile: add the ability to eat InvertFlags to ADCQ and SBBQ

  4. Jorropo commented on Jun 7, 2026

    @Jorropo
    MemberAuthor

    It's just gonna ICE, it's not too bad, removing release-blocker.

  5. randall77 commented on Jun 8, 2026

    @randall77
    Contributor

    What was the CL that triggered this?

  6. Jorropo commented on Jun 9, 2026

    @Jorropo
    MemberAuthor
  7. added this to the Go1.27 milestone on Jun 10, 2026
  8. added a commit that references this issue on Jun 11, 2026
    9f9476d
  9. gopherbot commented on Oct 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/848405 mentions this issue: cmd/compile: use memory operands in amd64 carry chains

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FixPendingIssues that have a fix which has not yet been reviewed or submitted.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions