Skip to content

[APX] refactor APX-EVEX emitter#129915

Open
Ruihan-Yin wants to merge 4 commits into
dotnet:mainfrom
Ruihan-Yin:apx-refactor-public
Open

[APX] refactor APX-EVEX emitter#129915
Ruihan-Yin wants to merge 4 commits into
dotnet:mainfrom
Ruihan-Yin:apx-refactor-public

Conversation

@Ruihan-Yin

@Ruihan-Yin Ruihan-Yin commented Jun 26, 2026

Copy link
Copy Markdown
Member

Contribute to #117326

Overview of this PR:
As tanner suggested, the first goal for this PR is to get rid of TakesApxExtendedEvexPrefix and let TakesEvexPrefix manage all the cases when EVEX is needed, both original SIMD EVEX, and extended EVEX introduced by APX.

The expected outcome is to reach better readability, and better robustness. meanwhile have little to no impact on throughput.

After the PR:
TakesEvexPrefix will gate all the EVEX use cases, and IsEvexEcodableInstruction will confirm the EVEX encodability for both SIMD and APX instruction. This makes fewer places that need to be updated if more APX instructions or feature comes.

To revert

optimize tp

bug fixes

tp-fix

Clean up

clean up

Clean up
@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 Jun 26, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 26, 2026
@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.

Copilot AI 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 refactors xarch emitter/APX encoding classification by introducing an explicit Encoding_APX_EVEX flag and consolidating EVEX gating so APX “extended EVEX” cases flow through the existing TakesEvexPrefix / IsEvexEncodableInstruction logic rather than a separate TakesApxExtendedEvexPrefix path.

Changes:

  • Adds Encoding_APX_EVEX (and an INS_FLAGS_APX_EVEX_PROMOTABLE mask) to mark APX EVEX-only / EVEX-promotable instructions in the instruction metadata.
  • Removes TakesApxExtendedEvexPrefix and updates prefix selection/sizing logic to rely on TakesEvexPrefix, with SIMD-only queries split into IsSimdVexOrEvexEncodableInstruction and IsSimdEvexEncodableInstruction.
  • Updates EVEX encodability and EVEX prefix emission to correctly handle APX-promoted legacy/VEX/APX-only instructions, including MAP4 handling for legacy/APX-only EVEX promotion.

Reviewed changes

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

File Description
src/coreclr/jit/instrsxarch.h Marks APX-only/APX EVEX-form instructions with Encoding_APX_EVEX to drive unified EVEX gating.
src/coreclr/jit/instr.h Introduces Encoding_APX_EVEX and INS_FLAGS_APX_EVEX_PROMOTABLE to classify APX EVEX promotion capability.
src/coreclr/jit/emitxarch.h Removes TakesApxExtendedEvexPrefix declaration and adds SIMD-scoped EVEX/VEX query helpers.
src/coreclr/jit/emitxarch.cpp Refactors EVEX encodability/prefix selection and updates sizing/output paths to account for APX-promoted EVEX behavior.

@Ruihan-Yin

Copy link
Copy Markdown
Member Author

Build analysis is green, and copliot left no comments.

Hi @tannergooding, can you please take a look at this PR? Thanks! :)

@JulieLeeMSFT

Copy link
Copy Markdown
Member

LGTM.
Traced the flag checks, prefix selection, and stress-mode handling against the source — behavior is preserved and the cleanup is solid. Removing TakesApxExtendedEvexPrefix() and routing everything through IsEvexEncodableInstruction()/TakesEvexPrefix() via explicit metadata flags is a nice simplification. KMOV/BMI correctly moved to DoJitStressPromotedEvexEncoding() (MAP4, not standard VEX→EVEX), and the Map-4 prefix logic + comment are correct. No blocking concerns.

🤖 AI-generated code review

@JulieLeeMSFT JulieLeeMSFT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

3 participants