Repository navigation
Description
Proposal Details
Go currently targets the z13 instruction set as the minimum when building for GOARCH=s390x. This has been the case since Go 1.19, as documented in the source:
src/runtime/os_linux_s390x.go: "Starting with Go1.19, z13 is the minimum machine level for running Go on LoZ"src/cmd/go/internal/work/exec.go: hardcoded-march=z13passed to the C compiler for CGo builds
IBM Z has continued to evolve since z13, with each generation introducing new hardware facilities and instructions that could be exploited by the compiler and hand-coded assembly in the runtime and standard library to improve performance. However, the compiler cannot currently use those instructions without a runtime check, as it must generate code that runs safely on all supported IBM Z hardware (z13 and later).
This proposal adds GOS390X, an s390x-specific environment variable that allows the compiler and assembly language functions to assume the presence of instructions introduced after z13, without requiring runtime checks.
Suggested values for GOS390X
The values map directly to IBM Z hardware generations.
| Value | IBM Z Model | Key new facilities / instructions |
|---|---|---|
z13 |
z13 | VX, MSA3 ,MSA4, MSA5 — default |
z14 |
z14 | VXE, MSA6, MSA7, MSA8 , MIE2 |
z15 |
z15 | MSA9, Vector-enhancements facility 2(VXE2), MIE3 |
z16 |
z16 | Neural-network-processing-assist facility, BEAR |
z17 |
z17 | Vector-enhancements facility 3(VXE3), MIE4 |
Each generation is a strict superset of the previous. Setting GOS390X=z15 implies all z13 and z14 instructions are also available. This is the same superset model used by GOPPC64.
The default is z13, consistent with the Go 1.19+ minimum hardware requirement.
Semantics
GOS390X=z13 (default) — current behaviour, no change to generated code
GOS390X=z14 — compiler and assembler may emit instructions introduced in z14 and below
GOS390X=z15 — compiler and assembler may emit instructions introduced in z15 and below
GOS390X=z16 — compiler and assembler may emit instructions introduced in z16 and below
GOS390X=z17 — compiler and assembler may emit instructions introduced in z17 and below
Activity
gabyhelp commentedon Jul 29, 2026
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
srinivas-pokala commentedon Aug 12, 2026
@ianlancetaylor @rsc @randall77 could you please review this proposal.
randall77 commentedon Aug 18, 2026
Seems reasonable to me.
What instructions would be used from these later instruction sets? What is currently guarded by a runtime check that would no longer have to be?
srinivas-pokala commentedon Aug 27, 2026
GOS390X=z13 (default — already the hard minimum since Go 1.19)
math/big, internal/bytealg, vendor/x/crypto
GOS390X=z14
GOS390X=z15
GOS390X=z16
GOS390X=z17
Since z13 is already the hard minimum (checkS390xCPU() in
src/runtime/os_linux_s390x.go exits if HasVX is false), cpu.S390X.HasVX is
already guaranteed true at runtime — the compiler just doesn't know it
statically. GOS390X=z13 makes it a compile-time constant, dead-code-eliminating
all scalar fallbacks:
[-]all: add GOS390X environment variable[/-][+]proposal: all: add GOS390X environment variable[/+]srinivas-pokala commentedon Sep 28, 2026
@rsc @ianlancetaylor @randall77 could you please review the proposal