[AMD64][APX] Introduce the remaining NCI instructions - CTEST, CFCMOV#127536
[AMD64][APX] Introduce the remaining NCI instructions - CTEST, CFCMOV#127536Ruihan-Yin wants to merge 17 commits into
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
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. |
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
|
Failures look unrelated. Hi, @tannergooding @kg, please take a look at this PR, thanks :) |
kg
left a comment
There was a problem hiding this comment.
Looks okay to me but will defer full review and approval to Tanner. Left a few comments.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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_Inow acceptsinstOptions, but (in the shown hunk) doesn’t apply it to the emitted instruction descriptor (e.g., viaSetEvexNfIfNeeded/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 onidin this emitter helper, consistent with otheremitIns_*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))
{
|
Failures look unrelated. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Introduce the renaming APX-NCI instructions:
CTESTccandCFCMOVccCTESTcc:

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:

There is no CFCMOV optimization in JIT at the moment.