Skip to content

JIT: Restore insertps source-lane fold for floating-point inserts - #135382

Merged
dhartglassMSFT merged 1 commit into
dotnet:mainfrom
Ruihan-Yin:issue-134942
Oct 12, 2026
Merged

dhartglassMSFT merged 1 commit into
dotnet:mainfrom
Ruihan-Yin:issue-134942

Conversation

@Ruihan-Yin

Copy link
Copy Markdown
Member

The fold that rewrites Insert(v, CreateScalarUnsafe(v2.GetElement(n)), imm) into a single insertps selecting lane n via count_s (#130422) was gated on op2 still being a CreateScalarUnsafe node. #130444 later started removing floating-point CreateScalarUnsafe nodes whose user is another HW intrinsic, and since operands are lowered before their users, the wrapper is always gone by the time the Insert is lowered. The fold therefore never fired, leaving a redundant movshdup/unpckhps/shufps ahead of every such insertps.

Also recognize the bare extraction as op2. Adds a disasm-checked test, since the existing functional test could not catch the lost fold.

Fixes #134942

Note: This PR was authored with the assistant of AI.

The fold that rewrites Insert(v, CreateScalarUnsafe(v2.GetElement(n)), imm)
into a single insertps selecting lane n via count_s (dotnet#130422) was gated on op2
still being a CreateScalarUnsafe node. dotnet#130444 later started removing
floating-point CreateScalarUnsafe nodes whose user is another HW intrinsic,
and since operands are lowered before their users, the wrapper is always gone
by the time the Insert is lowered. The fold therefore never fired, leaving a
redundant movshdup/unpckhps/shufps ahead of every such insertps.

Also recognize the bare extraction as op2. Adds a disasm-checked test, since
the existing functional test could not catch the lost fold.

Fixes dotnet#134942

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 8, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 8, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

@Ruihan-Yin
Ruihan-Yin marked this pull request as ready for review October 8, 2026 18:21
@Ruihan-Yin

Copy link
Copy Markdown
Member Author

cc @dhartglassMSFT @tannergooding

@dhartglassMSFT

Copy link
Copy Markdown
Contributor

lgtm, thanks for looking at this Ruihan

@dhartglassMSFT
dhartglassMSFT merged commit 523a36f into dotnet:main Oct 12, 2026
156 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 14, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: x64 INSERTPS source-lane fold is unreachable, so Insert(v, <lane N>) keeps a redundant shuffle

2 participants