Skip to content

cmd/compile: archsimd load isn't treated as read only for string → []byte elision #81097

Open

Description

@Jorropo

Go version

go version go1.28-devel_9ea81f5213 Tue Aug 25 00:07: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='simd'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build661455473=/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.28-devel_9ea81f5213 Tue Aug 25 00:07:53 2026 -0700'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Compile:

package a

import "simd/archsimd"

func f(x string) archsimd.Uint8x16 {
	return archsimd.LoadUint8x16([]byte(x))
}

What did you see happen?

Call to stringtoslicebyte

What did you expect to see?

An XMM load from the string's backing array.

Activity

  1. Jorropo commented on Aug 25, 2026

    @Jorropo
    MemberAuthor

    Note I'm not asking for intrinsics that load from a string.
    I am trying to use this in the encoding/hex package (see CL 795820), sadly this patch adds a heap allocation in the DecodeString function:

    func DecodeString(s string) ([]byte, error) {
    	dst := make([]byte, DecodedLen(len(s)))
    	n, err := Decode(dst, []byte(s))
    	return dst[:n], err
    }

    If I had intrinsics to load from a string it would be painful to use since it adds color to the SIMD routines.

  2. gopherbot commented on Aug 26, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/822404 mentions this issue: [release-branch.go1.27] cmd: vendor changes for "go fix"

  3. dr2chase commented on Aug 28, 2026

    @dr2chase
    Contributor

    @golang/compiler

  4. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Aug 28, 2026
  5. self-assigned this
    on Sep 8, 2026
  6. added this to the Backlog milestone on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions