Skip to content

[AMD64][APX] Introduce the remaining NCI instructions - CTEST, CFCMOV#127536

Open
Ruihan-Yin wants to merge 17 commits into
dotnet:mainfrom
Ruihan-Yin:apx-nci-PR
Open

[AMD64][APX] Introduce the remaining NCI instructions - CTEST, CFCMOV#127536
Ruihan-Yin wants to merge 17 commits into
dotnet:mainfrom
Ruihan-Yin:apx-nci-PR

Conversation

@Ruihan-Yin
Copy link
Copy Markdown
Member

Introduce the renaming APX-NCI instructions: CTESTcc and CFCMOVcc

CTESTcc:
image

image

with CTEST, now CCMP reg, 0 can be optimized to CTEST reg, reg, which is self contained and 1-byte smaller, this optimization comes with the PR as well

CFCMOVcc:
image

There is no CFCMOV optimization in JIT at the moment.

Copilot AI review requested due to automatic review settings April 28, 2026 22:56
@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 Apr 28, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Apr 28, 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR extends the x64 JIT’s APX support by introducing new conditional instructions (CTEST and CFCMOV), updating EVEX/APX encoding paths in the emitter, and adding targeted emitter unit tests.

Changes:

  • Add APX instruction definitions for CFCMOV and CTEST (and related instruction-range markers).
  • Update emitter logic to recognize/encode these new conditional instructions and related EVEX fields (e.g., DFV/NF/ND handling).
  • Add AMD64 emitter unit tests covering CFCMOV and CTEST encodings and integrate them into the unit test dispatcher.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/coreclr/jit/instrsxarch.h Adds APX instruction definitions/ranges for CFCMOV + CTEST under TARGET_AMD64.
src/coreclr/jit/emitxarch.h Updates emitter APIs and adds helpers to classify APX conditional instructions.
src/coreclr/jit/emitxarch.cpp Implements new APX conditional classification and extends EVEX/APX emission logic (ND/NF/DFV, prefix/layout handling).
src/coreclr/jit/codegenxarch.cpp Adds CCMP-to-CTEST optimization for compare-with-zero and introduces emitter unit tests for CFCMOV/CTEST.
src/coreclr/jit/codegenlinear.cpp Wires new “cfcmov” and “ctest” unit test sections into genEmitterUnitTests().
src/coreclr/jit/codegen.h Declares new emitter unit test entry points and tightens AMD64-only helpers.

Comment thread src/coreclr/jit/instrsxarch.h Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/codegenxarch.cpp
Comment thread src/coreclr/jit/codegenxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/codegenxarch.cpp
Ruihan-Yin and others added 2 commits April 29, 2026 12:04
Co-authored-by: Copilot <copilot@github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/coreclr/jit/emitxarch.cpp
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 30, 2026 19:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/codegenxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp
Comment thread src/coreclr/jit/emitxarch.h Outdated
Comment thread src/coreclr/jit/instrsxarch.h Outdated
Co-authored-by: Copilot <copilot@github.com>
@Ruihan-Yin
Copy link
Copy Markdown
Member Author

Failures look unrelated.

Hi, @tannergooding @kg, please take a look at this PR, thanks :)

Comment thread src/coreclr/jit/codegenxarch.cpp Outdated
Comment thread src/coreclr/jit/codegenxarch.cpp Outdated
Comment thread src/coreclr/jit/codegenxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Copy link
Copy Markdown
Member

@kg kg left a comment

Choose a reason for hiding this comment

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

Looks okay to me but will defer full review and approval to Tanner. Left a few comments.

Copilot AI review requested due to automatic review settings May 11, 2026 19:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Comment thread src/native/minipal/cpufeatures.c Outdated
Comment thread src/coreclr/jit/instrsxarch.h
Comment thread src/coreclr/jit/codegenxarch.cpp Outdated
Comment thread src/coreclr/jit/codegenxarch.cpp
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Copilot AI review requested due to automatic review settings May 11, 2026 19:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/codegenxarch.cpp
Comment thread src/coreclr/jit/instr.h Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 11, 2026 20:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/coreclr/jit/emitxarch.cpp
Comment thread src/coreclr/jit/codegenxarch.cpp
Comment thread src/coreclr/jit/instrsxarch.h Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Copilot AI review requested due to automatic review settings May 12, 2026 16:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/coreclr/jit/emitxarch.cpp:9082

  • emitIns_C_I now accepts instOptions, but (in the shown hunk) doesn’t apply it to the emitted instruction descriptor (e.g., via SetEvexNfIfNeeded / SetEvexDFVIfNeeded / SetEvexNdIfNeeded). As a result, callers passing APX/EVEX options through this path may silently get incorrect encodings (missing NF/DFV/ND context). Consider setting the relevant EVEX contexts on id in this emitter helper, consistent with other emitIns_* routines updated in this PR.
void emitter::emitIns_C_I(
    instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fldHnd, int offs, int val, insOpts instOptions)
{
    // Static always need relocs
    if (!jitStaticFldIsGlobAddr(fldHnd))
    {

Comment thread src/coreclr/jit/emitxarch.h Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
@Ruihan-Yin Ruihan-Yin requested a review from kg May 12, 2026 20:52
@Ruihan-Yin
Copy link
Copy Markdown
Member Author

Failures look unrelated.

Copilot AI review requested due to automatic review settings May 14, 2026 21:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Comment thread src/coreclr/jit/codegenxarch.cpp
Comment thread src/coreclr/jit/emitxarch.cpp
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp
Comment thread src/coreclr/jit/codegenxarch.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 21:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

4 participants