Uh oh!
There was an error while loading. Please reload this page.
JIT: Accelerate floating->long casts on x86 - #125180
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends x86 JIT codegen to hardware-accelerate non-overflow floating→long/ulong casts using AVX-512 and AVX10.2, completing the remaining cast-acceleration work pulled from #116805.
Changes:
- Teach cast helper selection to allow floating↔long casts to stay intrinsic-based on x86 when AVX-512 is available.
- Add/extend x86 long decomposition logic to generate AVX-512/AVX10.2 sequences for floating→long/ulong and long→floating casts.
- Introduce a new AVX-512 scalar compare-mask intrinsic and wire it up for immediate bounds + containment.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/lowerxarch.cpp | Refactors vector constant construction and adds containment support for the new AVX-512 scalar compare-mask intrinsic. |
| src/coreclr/jit/hwintrinsicxarch.cpp | Adds immediate upper-bound handling for the new AVX-512 scalar compare-mask intrinsic. |
| src/coreclr/jit/hwintrinsiclistxarch.h | Introduces AVX512.CompareScalarMask as a new intrinsic mapping to vcmpss/vcmpsd with IMM. |
| src/coreclr/jit/flowgraph.cpp | Updates helper-requirement logic so x86 floating↔long casts can avoid helper calls when AVX-512 is available. |
| src/coreclr/jit/decomposelongs.cpp | Implements the AVX-512/AVX10.2-based lowering/decomposition sequences for floating↔long/ulong on x86. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
@dotnet/jit-contrib this is ready for review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
JulieLeeMSFT
commented
Apr 13, 2026
@EgorBo, please review this community PR. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/coreclr/jit/flowgraph.cpp:1347
fgCastRequiresHelperon x86 currently only exempts long<->floating casts whenInstructionSet_AVX512is enabled. This PR adds long/floating cast acceleration that can use AVX10.2 (InstructionSet_AVX10v2) as well (e.g.,DecomposeLongs::DecomposeCastcheckscompOpportunisticallyDependsOn(InstructionSet_AVX10v2)). If AVX10v2 is enabled while AVX512 is disabled/unavailable, morphing may still force a helper call and bypass the new codegen. Consider updating the x86 condition to treat AVX10v2 as sufficient (e.g., require helper only when neither AVX512 nor AVX10v2 is available).
#if defined(TARGET_X86) || defined(TARGET_ARM)
if ((varTypeIsLong(fromType) && varTypeIsFloating(toType)) ||
(varTypeIsFloating(fromType) && varTypeIsLong(toType)))
{
#if defined(TARGET_X86)
return !compOpportunisticallyDependsOn(InstructionSet_AVX512);
#else
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
saucecontrol
commented
Apr 22, 2026
Pushed a change to simplify the IR. No change to the codegen. |
Uh oh!
There was an error while loading. Please reload this page.
This adds floating->long/ulong cast codegen for AVX-512 and AVX10.2 on x86. With this, all non-overflow casts are now hardware accelerated. This is the last bit pulled from #116805.
Typical Diff (double->long AVX-512):
Full Diffs
Breakdown of the double->long asm: