Skip to content

Handle GT_CCMP in GenTree::OperConsumesFlags on TARGET_AMD64#127477

Merged
tannergooding merged 3 commits intomainfrom
copilot/handle-gtt-cmp-for-target-amd64
Apr 28, 2026
Merged

Handle GT_CCMP in GenTree::OperConsumesFlags on TARGET_AMD64#127477
tannergooding merged 3 commits intomainfrom
copilot/handle-gtt-cmp-for-target-amd64

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

GenTree::OperConsumesFlags handled GT_CCMP only on TARGET_ARM64, even though GT_CCMP is also emitted on TARGET_AMD64 (gated by #if defined(TARGET_ARM64) || defined(TARGET_AMD64) in gtlist.h).

Changes

  • src/coreclr/jit/gentree.h — Add a TARGET_AMD64 branch in OperConsumesFlags. GT_JCC, GT_SETCC, GT_SELECTCC, and GT_CCMP are declared sequentially in gtlist.h (intervening lines are only comments / #if guards), so their enum values are contiguous and a range check collapses 4 comparisons to 2 — matching the existing idiom used elsewhere in the file (e.g. OperIsCompare). A static_assert(AreContiguous(...)) guards the assumption, consistent with surrounding helpers.
#if defined(TARGET_ARM64)
        if (OperIs(GT_CCMP, GT_SELECT_INCCC, GT_SELECT_INVCC, GT_SELECT_NEGCC))
        {
            return true;
        }
        return OperIs(GT_JCC, GT_SETCC, GT_SELECTCC);
#elif defined(TARGET_AMD64)
        static_assert(AreContiguous(GT_JCC, GT_SETCC, GT_SELECTCC, GT_CCMP));
        return (GT_JCC <= gtOper) && (gtOper <= GT_CCMP);
#else
        return OperIs(GT_JCC, GT_SETCC, GT_SELECTCC);
#endif

Callers (lir.cpp, liveness.cpp, lower.cpp, sideeffects.cpp) will now correctly recognize AMD64 GT_CCMP as flag-consuming when ordering / scheduling around flag-producing nodes.

Note

This pull request was created by GitHub Copilot.

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/e9e0abb3-4b18-4e4d-b266-870cc5ed0607

Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 27, 2026 22:54
Copilot AI changed the title [WIP] Add handling for GT_CCMP in GenTree::OperConsumesFlags on TARGET_AMD64 Handle GT_CCMP in GenTree::OperConsumesFlags on TARGET_AMD64 Apr 27, 2026
Copilot AI requested a review from tannergooding April 27, 2026 22:55
Comment thread src/coreclr/jit/gentree.h
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/da52f1ef-5b60-4589-9a36-e3beb1fb4b03

Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 27, 2026 22:59
Copilot AI requested a review from tannergooding April 27, 2026 23:00
@tannergooding tannergooding marked this pull request as ready for review April 27, 2026 23:04
Copilot AI review requested due to automatic review settings April 27, 2026 23:04
@teo-tsirpanis teo-tsirpanis added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-Infrastructure labels Apr 27, 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.

Comment thread src/coreclr/jit/gentree.h
@tannergooding tannergooding merged commit 7e15c5c into main Apr 28, 2026
141 of 144 checks passed
@tannergooding tannergooding deleted the copilot/handle-gtt-cmp-for-target-amd64 branch April 28, 2026 13:01
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

Status: Done

Development

Successfully merging this pull request may close these issues.

GenTree::OperConsumesFlags doesn't handle GT_CCMP on TARGET_AMD64

5 participants