Skip to content

JIT: don't elide stack moves around EVEX embedded masks - #135005

Open
p6laris wants to merge 1 commit into
dotnet:mainfrom
p6laris:jit-stackmov-evex-mask
Open

p6laris wants to merge 1 commit into
dotnet:mainfrom
p6laris:jit-stackmov-evex-mask

Conversation

@p6laris

@p6laris p6laris commented Oct 1, 2026

Copy link
Copy Markdown

Fixes #135004

IsRedundantStackMov didn't account for EVEX embedded masking. After a masked store to a stack local it could drop the next full load or store of the same register and slot, even though the masked store had only written some of the elements.

The fix passes instOptions through and bails out when either the current instruction or emitLastIns has an embedded mask. That's slightly conservative: it also stops eliding a masked store that follows an unmasked load of the same slot, which was safe to drop.

Runtime_135004 fails without the fix and passes with it on AVX-512 hardware (Tiger Lake), and returns early when AVX-512 isn't available. SuperPMI asmdiffs on the windows-x64 collections show no diffs over 2.81M contexts, so none of them hit this pattern.

Found while looking at #134941.

IsRedundantStackMov didn't consider embedded masking, so after a masked
store to a stack local it could drop a following full load or store of
the same register and slot. A masked move only reads or writes the
selected elements, so the following move isn't a no-op.

Pass the instruction options through and bail out when either the
current instruction or the last emitted one has an embedded mask.

Fixes dotnet#135004
@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 1, 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 1, 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI 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: IsRedundantStackMov ignores EVEX embedded masks, dropping moves after a masked store to a stack local

1 participant