Skip to content

[WIP] Fix JIT unrolled memmove and initblk to emit vzeroupper - #134385

Closed
EgorBo with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-jit-memmove-vzeroupper-issue
Closed

EgorBo with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-jit-memmove-vzeroupper-issue

Conversation

Copilot AI commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

@EgorBo EgorBo added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 22, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 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.

@EgorBo

EgorBo commented Sep 22, 2026

Copy link
Copy Markdown
Member

@copilot try again

Copilot AI commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

@copilot try again

Done in 71d8e15.

Both sites in LinearScan::BuildBlockStore now pass the actual SIMD register width to SetContainsAVXFlags, matching what codegen emits:

  • BlkOpKindUnrollMemmove reuses the simdSize local that's already computed there.
  • Init-block BlkOpKindUnroll uses roundDownSIMDSize(size), except for IsOnHeapAndContainsReferences() where genCodeForInitBlkUnroll only uses SIMD on contiguous non-GC runs — there it uses the largest such run, so a GC struct whose runs only reach XMM doesn't get a pointless vzeroupper.

Verified before/after on the repro from the issue (linux-x64, AVX-512, checked JIT):

  • MemmoveUnroll / InitBlk: vzeroupper now in the epilog.
  • MemmoveThenPInvoke: the bogus prolog-only vzeroupper is gone, replaced by one before the P/Invoke and one in the epilog — matching the "Expected" section of the issue.
  • BlockCopy and XMM-only cases: unchanged.

Also checked PreferredVectorBitWidth=512/256/128 and EnableAVX512/AVX2/AVX/SSE42=0 (no asserts, vzeroupper correctly absent at 128), and ran JIT/Directed (208 tests, 198 passed, 0 failed). clang-format 17.0.6 reports no changes.

Per the issue's note, genStructPutArgUnroll (the other size-less SetContainsAVXFlags() at lsraxarch.cpp:1772) only ever emits EA_16BYTE, so I left it alone.

No tests added — let me know if you want a regression test for this.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: (bug) x64: unrolled memmove and initblk use YMM/ZMM but never emit vzeroupper

2 participants