Skip to content

JIT: Tail-merge process all sets at once#129363

Open
BoyBaykiller wants to merge 7 commits into
dotnet:mainfrom
BoyBaykiller:tail-merge-process-sets-at-once
Open

JIT: Tail-merge process all sets at once#129363
BoyBaykiller wants to merge 7 commits into
dotnet:mainfrom
BoyBaykiller:tail-merge-process-sets-at-once

Conversation

@BoyBaykiller

@BoyBaykiller BoyBaykiller commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Say we call tailMergePreds() with candidates: [A1, B2, C1, A3, B3, B1, A2].

Previously, it only processed one set at a time - let's say all the A's.
Then we'd regather all candidates in the caller, skipping the ones which where already processed with checks like
!block->KindIs(BBJ_RETURN, BBJ_THROW) || block->isEmpty() and call it again until it finds no more.

With this PR all sets are processed in a single call to tailMergePreds.
It works as follows. We start at index 0 (A1) find the matches (all the other A's) and make them continous in memory, so we get: [A1, A3, A2, B2, C1, B3, B1] after the first call to partition. We then advance by the number of matches (3) and continue at B2. After the next call to partition we get: [A1, A3, A2, B2, B3, B1, C1].

I didn't use the STL std::partiton, as discussed.

@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 13, 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 13, 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.

* move return/throw block dedulplication to before tail merge
* add partition impl, but don't use it yet
* remove 'already processed' check as its no longer needed
@BoyBaykiller BoyBaykiller force-pushed the tail-merge-process-sets-at-once branch from 106401d to 534ebff Compare June 29, 2026 20:03
@BoyBaykiller

Copy link
Copy Markdown
Contributor Author

@AndyAyersMS PTAL. The diffs are what I expected, with the exception of the tp regression on x86 - I have no clue why that is and I don't know a good way of finding out.

The tiny assembly diffs are only because I also moved return/throw merging to happen before tail-merge and sometimes the crossJumpVictim which would have been picked is now removed/empty.

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.

1 participant