Skip to content

proposal: all: add GOS390X environment variable #80621

Open

Description

@srinivas-pokala

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=z13 passed 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

  1. srinivas-pokala commented on Aug 12, 2026

    @srinivas-pokala
    ContributorAuthor

    @ianlancetaylor @rsc @randall77 could you please review this proposal.

  2. randall77 commented on Aug 18, 2026

    @randall77
    Contributor

    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?

  3. srinivas-pokala commented on Aug 27, 2026

    @srinivas-pokala
    ContributorAuthor

    What instructions would be used from these later instruction sets?

    GOS390X=z13 (default — already the hard minimum since Go 1.19)

    • Vector Facility: all SIMD ops (VL, VST, VFMA, etc.) used in math, hash/crc32,
      math/big, internal/bytealg, vendor/x/crypto
    • CPACF (MSA): KM/KIMD/KLMD — hardware AES-{128,192,256}, SHA-1/256/512

    GOS390X=z14

    • VXE (facility 135): adds support for BFP short format and BFP extended format instructions
    • MIE2: Added List of newer instructions
    • MSA8 (facility 146): KMA — AES-GCM hardware
    • MSA9/KDSA (facility 155): hardware ECDSA P256/P384/P521, EdDSA Ed25519/Ed448

    GOS390X=z15

    • VXE2 (facility 148): improved BFP vector ops
    • MIE3 (facility 154):Added List of newer instructions
    • DEFLATE-conversion: DFLTCC → compress/flate acceleration

    GOS390X=z16

    • Enhanced-Sort facility: SORT LISTS instruction
    • NNPA: Neural Network Processing Assist → ML inference ops
    • Neural-network-processing-assist facility
    • Processor-activity-instrumentation facility/extension-1
    • Vector-packed-decimal-enhancement facility

    GOS390X=z17

    • VXE3 (facility 198): extended vector BFP ops
    • MIE4: Added List of newer instructions
    • Message-security-assist extension 10/11/12/13 , add new CPACF cipher function codes
    • Vector-packed-decimal-enhancement facility 3

    What is currently guarded by a runtime check that would no longer have to be?

    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:

    Guard removed File What it protects
    cpu.S390X.HasVX hash/crc32/crc32_s390x.go Vectorized CRC32
    cpu.S390X.HasVX math/arith_s390x.go Vectorized sin/cos/exp/log/sqrt
    cpu.S390X.HasVX math/big/arithvec_s390x.go big.Int vectorized multiply
    cpu.S390X.HasVX internal/bytealg/index_s390x.go Vectorized substring search
    cpu.S390X.HasVX vendor/x/crypto/chacha20 ChaCha20 vector path
    cpu.S390X.HasVX vendor/x/crypto/poly1305 Poly1305 vector path
    cpu.S390X.HasAES/SHA*/GHASH crypto/aes, sha1, sha256, sha512, sha3, tls CPACF hardware crypto
    cpu.S390X.HasVXE SSA backend WFMAXDB/WFMINDB ops Float min/max
    cpu.S390X.HasAESGCM crypto/tls/cipher_suites.go TLS 1.3 AES-GCM fast path
    cpu.S390X.HasKDSA/HasECDSA/HasEDDSA crypto/ecdsa, fips140deps Elliptic curve hardware
  4. changed the title [-]all: add GOS390X environment variable[/-] [+]proposal: all: add GOS390X environment variable[/+] on Aug 30, 2026
  5. added this to the Proposal milestone on Aug 30, 2026
  6. srinivas-pokala commented on Sep 28, 2026

    @srinivas-pokala
    ContributorAuthor

    @rsc @ianlancetaylor @randall77 could you please review the proposal

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

Metadata

Metadata

Labels

Proposalarch-s390xIssues solely affecting the s390x architecture.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions