Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
[Wasm RyuJit] Enable Hardware Intrinsics by adamperlin · Pull Request #129201 · dotnet/runtime · GitHub
Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [Wasm RyuJit] Enable Hardware Intrinsics by adamperlin · Pull Request #129201 · dotnet/runtime · GitHub
Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [Wasm RyuJit] Enable Hardware Intrinsics by adamperlin · Pull Request #129201 · dotnet/runtime · GitHub
Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' [Wasm RyuJit] Enable Hardware Intrinsics by adamperlin · Pull Request #129201 · dotnet/runtime · GitHub
Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [Wasm RyuJit] Enable Hardware Intrinsics by adamperlin · Pull Request #129201 · dotnet/runtime · GitHub
Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' [Wasm RyuJit] Enable Hardware Intrinsics by adamperlin · Pull Request #129201 · dotnet/runtime · GitHub
Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); [Wasm RyuJit] Enable Hardware Intrinsics by adamperlin · Pull Request #129201 · dotnet/runtime · GitHub
Skip to content

[Wasm RyuJit] Enable Hardware Intrinsics - #129201

Merged
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton
Jun 16, 2026
Merged

[Wasm RyuJit] Enable Hardware Intrinsics#129201
adamperlin merged 27 commits into
dotnet:mainfrom
adamperlin:adamperlin/wasm-simd-skeleton

Conversation

@adamperlin

Copy link
Copy Markdown
Contributor

This is a follow up to #129140, so there is some duplicated diff. This PR enables FEATURE_SIMD and FEATURE_HW_INTRINSICS for TARGET_WASM and stubs out the minimal necessary pieces of implementation using a new NYI_WASM_SIMD macro and associated JitOption, NyiWasmSimdToR2RUnsupported to prevent crossgen failures due to the presence of intrinsics.

There are a few patterns that showed up commonly which required many ifdef adjustments:

  1. Assuming !TARGET_XARCH -> TARGET_ARM64 if hardware intrinsics are enabled (not the case anymore with wasm)
  2. Assuming FEATURE_HW_INTRINSICS -> FEATURE_MASKED_HW_INTRINSICS (not the case either for Wasm, as Wasm doesn't have any kind of mask register).

Stub HARDWARE_INTRINSIC definitions were added for quite a few xplat Vector128 operations even though these will not be worked on until further in the implementation plan, since the existence of these intrinsics was assumed with FEATURE_HARDWARE_INTRINSICS in many places.

CopilotAI review requested due to automatic review settings June 10, 2026 01:10
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 10, 2026

CopilotAI 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 wires up WebAssembly (Wasm32) support for CoreCLR JIT hardware intrinsics/SIMD at the infrastructure level: new instruction set definitions, JIT/EE interface plumbing, and Wasm-specific stubs/NYI paths to keep R2R/crossgen from failing while the implementation is still incomplete.

Changes:

  • Add Wasm32 instruction set + ReadyToRun instruction set definitions (WasmBase, PackedSimd, Vector128) and propagate them through the JIT interface/tooling.
  • Enable FEATURE_SIMD/FEATURE_HW_INTRINSICS for the standalone Wasm JIT build and add initial Wasm-specific HWIntrinsic plumbing (import/lower/codegen stubs and intrinsic lists).
  • Introduce NYI_WASM_SIMD + a new JitConfig switch and ensure wasm crossgen uses it to convert NYIs into R2R-unsupported skips.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
FileDescription
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.csMaps Wasm32 to TARGET_WASM for generated native ifdefs.
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txtAdds Wasm32 ISA definitions and R2R bits for WasmBase/PackedSimd.
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.csAdds Wasm32 instruction sets and implication expansion in managed JIT interface helpers.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.csMaps Wasm32 instruction sets to R2R instruction set enums.
src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.csAdds new R2R enum values for WasmBase/PackedSimd.
src/coreclr/jit/valuenumfuncs.hIncludes Wasm HWIntrinsic VN function defs and defines the HWIntrinsic VN range for Wasm.
src/coreclr/jit/valuenum.cppGates masked-intrinsic VN evaluation/constant folding and adjusts ISA-specific handling for Wasm.
src/coreclr/jit/targetwasm.hUpdates Wasm SIMD register sizing/ABI constants and defines SIMD-related feature macros.
src/coreclr/jit/regset.hAllows SIMD temp sizing to use FP/SIMD register size on Wasm.
src/coreclr/jit/registeropswasm.cppMaps SIMD types to Wasm v128 and treats v128 as a valid “float” reg kind.
src/coreclr/jit/namedintrinsiclist.hAdds Wasm HWIntrinsic list inclusion to populate NI_* for Wasm.
src/coreclr/jit/morph.cppAdds Wasm NYI stubs and gates masked-intrinsics-specific morphing logic.
src/coreclr/jit/lowerwasm.cppAdds Wasm lowering/containment NYI hooks for HWIntrinsic nodes.
src/coreclr/jit/jitconfigvalues.hAdds JitWasmSimdNyiToR2RUnsupported config knob.
src/coreclr/jit/importercalls.cppAdjusts intrinsic namespace matching for Wasm and prevents some HWIntrinsic paths on Wasm.
src/coreclr/jit/hwintrinsicwasm.cppNew Wasm HWIntrinsic helper stubs (lookup ISA, immediates, special imports).
src/coreclr/jit/hwintrinsiclistwasm.hNew Wasm HWIntrinsic list (initial Vector128 cross-platform surface, mostly stubbed).
src/coreclr/jit/hwintrinsiccodegenwasm.cppNew Wasm HWIntrinsic codegen entrypoint stub.
src/coreclr/jit/hwintrinsic.hAdds Wasm HWIntrinsic categories/flags and integrates them into common helpers.
src/coreclr/jit/hwintrinsic.cppAdds Wasm HWIntrinsic info array + ISA range array entry (currently incomplete).
src/coreclr/jit/gentree.cppAdjusts node sizing for Wasm HWIntrinsic nodes and gates masked-intrinsics helpers.
src/coreclr/jit/error.hIntroduces NYI_WASM_SIMD macro behavior with R2R-unsupported option.
src/coreclr/jit/compiler.hGates masked-intrinsic-only helpers and enables vector-length helpers for Wasm.
src/coreclr/jit/codegenlinear.cppEnables multi-op consume logic for Wasm by shifting #ifndef TARGET_WASM region.
src/coreclr/jit/codegen.hRestricts mask-constant overload to masked-intrinsics builds.
src/coreclr/jit/CMakeLists.txtEnables SIMD/HWIntrinsic defines for Wasm standalone JIT build + adds new Wasm sources.
src/coreclr/jit/assertionprop.cppNotes Wasm TODOs for CTZ/CLZ range reasoning.
src/coreclr/jit/abi.cppTreats 12-byte FP segments as SIMD register types on Wasm when SIMD enabled.
src/coreclr/inc/readytoruninstructionset.hAdds native R2R instruction set enum values for WasmBase/PackedSimd.
src/coreclr/inc/jiteeversionguid.hUpdates JIT/EE interface GUID due to instruction set contract changes.
src/coreclr/inc/corinfoinstructionset.hAdds Wasm CORINFO instruction set enum values and implication validity rules.
src/coreclr/crossgen-corelib.projPasses the new SIMD NYI-to-R2R-unsupported config option for wasm crossgen.

Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp Outdated
Comment threadsrc/coreclr/jit/hwintrinsiclistwasm.h
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings June 10, 2026 18:30

CopilotAI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI review requested due to automatic review settings June 10, 2026 20:01
CopilotAI review requested due to automatic review settings June 12, 2026 03:19

CopilotAI 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

Copilot reviewed 32 out of 32 changed files in this pull request and generated 5 comments.

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/morph.cpp
Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
CopilotAI review requested due to automatic review settings June 12, 2026 23:15

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/abi.cpp:131

  • For Size==12 (Vector3 / TYP_SIMD12), this currently falls through to case 16 and returns TYP_SIMD16. That contradicts the comment for GetRegisterType (“smallest type larger or equal to Size”) and can lose the distinction between SIMD12 vs SIMD16 in later handling (SIMD12 has special casing in multiple backends).
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
#endif

Comment threadsrc/coreclr/jit/hwintrinsiccodegenwasm.cpp
Comment threadsrc/coreclr/jit/lowerwasm.cpp
Comment threadsrc/coreclr/jit/hwintrinsic.cpp
Comment threadsrc/coreclr/jit/valuenum.cpp
CopilotAI review requested due to automatic review settings June 15, 2026 20:49

CopilotAI 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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/valuenum.cpp:8359

  • This switch (ni) case body is no longer properly guarded for TARGET_WASM: the case NI_ArmBase_LeadingZeroCount / case NI_AVX2_LeadingZeroCount labels are removed by the preprocessor, but the { ... return ... } block is still compiled as an unlabeled statement inside the switch. It's currently unreachable, but it's brittle and could become reachable via fallthrough, and it makes the switch structure incorrect for Wasm builds.
#if defined(TARGET_ARM64)
case NI_ArmBase_LeadingZeroCount:
#elif defined(TARGET_XARCH)
case NI_AVX2_LeadingZeroCount:
#endif
{
assert(!varTypeIsSmall(type) && !varTypeIsLong(type));

Comment threadsrc/coreclr/jit/hwintrinsicwasm.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/gentree.cpp
Comment threadsrc/coreclr/jit/morph.cpp
@adamperlin

Copy link
Copy Markdown
ContributorAuthor

/ba-g infra failures

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

@AndyAyersMS Can you take another look? I've made some pushes since the last review since I had to adjust superpmi collection and replay due to the presence of the new NyiWasmSimd option.

@adamperlin
adamperlin merged commit 67df812 into dotnet:mainJun 16, 2026
136 of 140 checks passed
@adamperlin
adamperlin deleted the adamperlin/wasm-simd-skeleton branch June 16, 2026 16:28
@pavelsavarapavelsavara added the arch-wasm WebAssembly architecture label Jun 17, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@dotnet-milestone-botdotnet-milestone-botBot added this to the 11.0-preview6 milestone Jun 17, 2026
eiriktsarpalis pushed a commit that referenced this pull request Jul 15, 2026
This is a follow up to #129140, so there is some duplicated diff. This
PR enables `FEATURE_SIMD` and `FEATURE_HW_INTRINSICS` for `TARGET_WASM`
and stubs out the minimal necessary pieces of implementation using a new
`NYI_WASM_SIMD` macro and associated JitOption,
`NyiWasmSimdToR2RUnsupported` to prevent crossgen failures due to the
presence of intrinsics.
There are a few patterns that showed up commonly which required many
ifdef adjustments:
1. Assuming `!TARGET_XARCH` -> `TARGET_ARM64` if hardware intrinsics are
enabled (not the case anymore with wasm)
2. Assuming `FEATURE_HW_INTRINSICS` -> `FEATURE_MASKED_HW_INTRINSICS`
(not the case either for Wasm, as Wasm doesn't have any kind of mask
register).
Stub `HARDWARE_INTRINSIC` definitions were added for quite a few xplat
`Vector128` operations even though these will not be worked on until
further in the implementation plan, since the existence of these
intrinsics was assumed with `FEATURE_HARDWARE_INTRINSICS` in many
places.
---------
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jul 18, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR 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.

4 participants

@adamperlin@AndyAyersMS@pavelsavara