Skip to content

jit: reuse shared-penalty physregs across preds#9696

Open
igogo-x86 wants to merge 2 commits into
facebook:masterfrom
igogo-x86:jit-align-consensus-livein
Open

jit: reuse shared-penalty physregs across preds#9696
igogo-x86 wants to merge 2 commits into
facebook:masterfrom
igogo-x86:jit-align-consensus-livein

Conversation

@igogo-x86

Copy link
Copy Markdown
Contributor

When a block has several Vregs that share the same penalty vector, the per-Vreg penalty tweaks in color_block_initialize don’t enforce a consistent ordering. We can end up with the right physreg set but in a different order than predecessors, so extra edge copies get inserted. After coloring, reorder shared-penalty groups to match the ordering chosen by already-processed predecessors when they agree, keeping the pattern stable and avoiding those redundant copies.

This is guarded to AArch64: without xchg, an inconsistent ordering forces a copy2 that lowers to three 4-byte instructions, whereas x86 would emit a single 2-byte xchg.

When a block has several Vregs that share the same penalty vector, the
per-Vreg penalty tweaks in color_block_initialize don’t enforce a
consistent ordering. We can end up with the right physreg set but in a
different order than predecessors, so extra edge copies get inserted.
After coloring, reorder shared-penalty groups to match the ordering
chosen by already-processed predecessors when they agree, keeping the
pattern stable and avoiding those redundant copies.

This is guarded to AArch64: without xchg, an inconsistent ordering
forces a copy2 that lowers to three 4-byte instructions, whereas x86
would emit a single 2-byte xchg.
@meta-codesync

meta-codesync Bot commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D89387615. (Because this pull request was imported automatically, there will not be any future comments.)

}
}

if (arch() == Arch::ARM)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@igogo-x86 Thanks for making the PR!

Sharing internal reviews here:

Nitpick: Braces for if statement unless it can all fit on one line.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@igogo-x86 has updated the pull request. You must reimport the pull request before landing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants