Skip to content

JIT: Tail-merge robust crossJumpVictim selection#129141

Merged
EgorBo merged 4 commits into
dotnet:mainfrom
BoyBaykiller:robust-crossJumpVictim
Jun 29, 2026
Merged

JIT: Tail-merge robust crossJumpVictim selection#129141
EgorBo merged 4 commits into
dotnet:mainfrom
BoyBaykiller:robust-crossJumpVictim

Conversation

@BoyBaykiller

@BoyBaykiller BoyBaykiller commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Previously, crossJumpVictim selection logic was dependent on the order of candidates which can lead to random diffs.

I removed the early out and added a tie-break which makes it order independent and sets the stage for a follow up zero-diff PR that processes all sets at once.
For the tie-break I used: predBlock->bbNum < crossJumpVictim->bbNum. This actually has few good diffs because it preferences away from BBF_NEEDS_GCPOLL blocks for some reason. I'd be nice to add that as a seperate heuristic instead of being implicitly encoded in the tie-break.

@BoyBaykiller BoyBaykiller changed the title JIT: Robust crossJumpVictim JIT: Tail-merge robust crossJumpVictim Jun 8, 2026
@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 8, 2026
@BoyBaykiller BoyBaykiller changed the title JIT: Tail-merge robust crossJumpVictim JIT: Tail-merge robust crossJumpVictim selection Jun 9, 2026
@BoyBaykiller BoyBaykiller force-pushed the robust-crossJumpVictim branch from 4ef215d to cba2e61 Compare June 11, 2026 02:17
* don't early out
* make NoGcPoll preference explicit
@BoyBaykiller

BoyBaykiller commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@AndyAyersMS PTAL. Makes the crossJumpVictim selection robust by introducing a tie-break and removing early out. Now, no matter the order of candidates, we always pick the same. This avoids spurious diffs in future changes. In particular, my goal is to follow up with a zero-diff PR that processes all sets at once.

There are some few good diffs from avoiding splitting of from BBF_NEEDS_GCPOLL blocks.

Comment thread src/coreclr/jit/fgopt.cpp Outdated
Comment thread src/coreclr/jit/fgopt.cpp

@AndyAyersMS AndyAyersMS 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.

LGTM

@EgorBo can you also review

Comment thread src/coreclr/jit/fgopt.cpp

bool const isNoSplit = stmt == predBlock->firstStmt();
bool const isFallThrough = (predBlock->KindIs(BBJ_ALWAYS) && predBlock->JumpsToNext());
auto getRank = [=]() -> unsigned {

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.

not sure I understand why you wrapped it to a single-use lambda, not a big fan of this approach.

@EgorBo EgorBo enabled auto-merge (squash) June 29, 2026 19:45
@EgorBo EgorBo merged commit b6f8d20 into dotnet:main Jun 29, 2026
138 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jun 30, 2026
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

None yet

Development

Successfully merging this pull request may close these issues.

3 participants