Skip to content

[wasm] Bail R2R for all SIMD parameter sizes, not just SIMD16#130391

Merged
lewing merged 1 commit into
dotnet:mainfrom
lewing:lewing-wasm-simd8-param-bail
Jul 9, 2026
Merged

[wasm] Bail R2R for all SIMD parameter sizes, not just SIMD16#130391
lewing merged 1 commit into
dotnet:mainfrom
lewing:lewing-wasm-simd8-param-bail

Conversation

@lewing

@lewing lewing commented Jul 9, 2026

Copy link
Copy Markdown
Member

Vector2 (TYP_SIMD8) and Vector3 (TYP_SIMD12) parameters are lowered to i32 in the wasm signature, the same as Vector128 (TYP_SIMD16), but the argument-spill prolog in genBeginFnProlog only bailed R2R for TYP_SIMD16.

As a result, a method with an 8-byte SIMD parameter — e.g. System.Numerics.Matrix3x2.CreateRotation(float, Vector2) — emitted an f64.store fed by the i32 parameter local, producing an invalid module that fails wasm validation:

func 20691 failed to validate
  type mismatch: expected f64, found i32

This currently prevents System.Private.CoreLib from producing a valid R2R image (both single-file and composite).

Fix

Broaden the parameter bail from == TYP_SIMD16 to varTypeIsSIMD(...) so SIMD8/SIMD12/SIMD16 parameters are all sent to the interpreter until SIMD parameters are supported in the wasm calling convention.

This is a direct follow-up to the SIMD16 parameter bail added in #130101 ("Fix a few missing SIMD bail outs that prevent SPC from validating") — it was the same class of bug, just missed for the smaller SIMD sizes.

Validation

With this change, crossgen2 --targetos wasi --targetarch wasm on System.Private.CoreLib (and a composite including it) produces a module that passes wasm-tools validate --features all. Verified locally on macOS/arm64.

Note

This change was authored with the assistance of GitHub Copilot.

Vector2 (TYP_SIMD8) and Vector3 (TYP_SIMD12) parameters are lowered to
i32 in the wasm signature, the same as Vector128 (TYP_SIMD16), but the
argument-spill prolog only bailed R2R for TYP_SIMD16. As a result a
method with an 8-byte SIMD parameter (e.g. System.Numerics.Matrix3x2
.CreateRotation(float, Vector2)) emitted an f64.store fed by the i32
parameter local, producing an invalid module that fails wasm
validation ("type mismatch: expected f64, found i32").

Broaden the parameter bail in genBeginFnProlog from `== TYP_SIMD16` to
`varTypeIsSIMD(...)` so SIMD8/SIMD12/SIMD16 parameters are all sent to
the interpreter until SIMD parameters are supported in the wasm calling
convention. This is a follow-up to the SIMD16 bail added in dotnet#130101 and
lets System.Private.CoreLib produce a valid R2R image.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 9, 2026 01:28
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 9, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@lewing lewing requested review from a team and AndyAyersMS July 9, 2026 01:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WASM JIT’s R2R-bail logic to treat all SIMD-typed parameters (e.g., TYP_SIMD8/TYP_SIMD12/TYP_SIMD16) as unsupported for WASM ReadyToRun codegen, ensuring crossgen2 doesn’t emit invalid WASM modules when such parameters are present.

Changes:

  • Broadened the prolog check from TypeGet() == TYP_SIMD16 to varTypeIsSIMD(TypeGet()), so any SIMD parameter triggers NYI_WASM_SIMD(...).
  • Updated the associated comment and NYI message to reflect the generalized “SIMD parameter” behavior.

@AndyAyersMS AndyAyersMS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully we get ABI support for SIMD types soon.

@lewing

lewing commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

/ba-g x64 timeouts are not related to wasm only change

@lewing lewing merged commit 95286f1 into dotnet:main Jul 9, 2026
131 of 139 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants