Skip to content

[wasm] Make simd128 part of the base instruction set and stop exposing it as configurable #137553

Open

Description

@lewing

On CoreCLR wasm, the JIT always treats PackedSimd (Wasm simd128) and Vector128 as part of the required baseline (src/coreclr/jit/compiler.cpp: "Ensure required baseline ISAs are supported in JIT code, even if not passed in by the VM"), and the VM sets InstructionSet_PackedSimd unconditionally in EEJitManager::SetCpuInfo. In practice simd128 cannot be turned off.

crossgen2 and ILC still accept it as a configurable instruction set: --instruction-set:-simd128 is accepted, yet the output still contains v128 code and PackedSimd.IsSupported stays true. That suggests a configuration that doesn't exist.

As suggested in #137112 (comment), make simd128 non-optional on wasm, the way SSE2 is part of base on x86:

  • Fold PackedSimd/simd128 into the wasm base instruction set in the instruction-set definitions and the generated tables.
  • Stop accepting simd128/packedsimd as a configurable instruction set in crossgen2 and ILC, and remove it from --help.
  • Update the JIT and the R2R instruction-set encoding to match. This likely needs a JIT-EE version bump.

relaxed-simd stays optional.

Trimming

Once simd128 is part of base, PackedSimd.IsSupported, Vector128.IsHardwareAccelerated and Vector.IsHardwareAccelerated are constant true on wasm, so the trimmer should fold them, as the x86/Arm substitutions embedded in CoreLib already do.

Without folding, everything reachable only from the non-SIMD fallback branches ships as both IL and R2R code. In the BCL that's small: a SIMD-heavy trimmed WASI app saved about 1.8 KB brotli. But user code can put anything behind those checks, so the cost is unbounded.

Precondition: the CoreCLR interpreter reports these as false and throws PlatformNotSupportedException for the PackedSimd intrinsics. Folding is only safe once it reports true and executes them, as Mono's interpreter does. Otherwise interpreted methods, such as generic Vector128<T> instantiations missing from the composite, would throw. That also delivers consistent IsSupported whether or not code is interpreted, and removes the roughly 100x interpreter slowdown for TensorPrimitives. Relaxed SIMD stays optional and is out of scope.

Note

This issue was generated with GitHub Copilot.

Activity

  1. added
    arch-wasmWebAssembly architecture
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Nov 14, 2026
  2. dotnet-policy-service commented on Nov 14, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  3. dotnet-policy-service commented on Nov 14, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  4. added this to the 12.0.0 milestone on Nov 16, 2026
  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions