Skip to content

cmd/compile: arm64 Broadcast* generates dead VMOVI/VMOV before VDUP instead of single DUP/LD1R #81352

Open

Description

@DrGo

Go version

go version go1.27.1 darwin/arm64

Output of go env in your module/workspace:

AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN='/Users/drgo/local/bin'
GOCACHE='/Users/drgo/ramdisk/gobuild'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/drgo/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT='greenteagc,newinliner,jsonv2,simd'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1174145987=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/drgo/local/code/contrib/gosmidarm/reports/broadcast/go.mod'
GOMODCACHE='/Users/drgo/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPACKAGESDRIVER=''
GOPATH='/Users/drgo/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.27.1/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/drgo/Library/Application Support/go/telemetry'
GOTMPDIR='/tmp'
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.27.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.27.1'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

BroadcastFloat64x2 is generated as zero, insert lane 0, dup lane 0:
Same shape for every Broadcast*.

func BroadcastFloat64x2(x float64) Float64x2 {
    var z Float64x2
    return z.SetElem(0, x).broadcast1To2()
}

### What did you see happen?

VMOVI $0, V1.B16
VMOV  V0.D[0], V1.D[0]
VDUP  V1.D[0], V0.D2

DUP overwrites both lanes, so the zero is dead.

What did you expect to see?

One-instruction:

  • scalar already in an FPR/GPR: DUP Vd.2D, Vn.D[0] or DUP Vd.2D, Xn
  • scalar in memory: LD1R {Vd.2D}, [Xn]

Activity

  1. prattmic commented on Sep 4, 2026

    @prattmic
    Member

    cc @golang/compiler @dr2chase @JunyangShao

  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Sep 4, 2026
  3. gopherbot commented on Sep 5, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/827904 mentions this issue: cmd/compile: fold arm64 broadcasts of inserted scalars

  4. added 2 commits that reference this issue on Sep 6, 2026
  5. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Sep 15, 2026
  6. added this to the Go1.28 milestone on Sep 15, 2026
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.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions