Skip to content

docs: asm def-sets hold every asm-written local of the enclosing blocks - #481

Merged
gynt merged 1 commit into
sourcehold:mainfrom
kotijekriv:fix/msvc-backend-asm-def-set
Nov 24, 2026
Merged

gynt merged 1 commit into
sourcehold:mainfrom
kotijekriv:fix/msvc-backend-asm-def-set

Conversation

@kotijekriv

Copy link
Copy Markdown
Contributor

The slot-tiebreak section of tools/compiler-internals/msvc-backend.md (point 3 of "The slot tiebreak, decoded") said an __asm block's def-set is the locals that block writes. It holds more than that, and the difference moves slots.

What slot_probe.py shows. Every asm block puts into its def-set each local that any asm block of the function writes, as long as the local is declared in a block that contains it. Where in that block the declaration stands does not matter. The def-set is walked twice per block, so such a local gets +2 from every asm block inside its declaring block, even one that never names it.

In TextureRenderCore::renderUnitAnimationWithBlendingUnk (0x00451E00: four asm blocks, a 0x1c frame, so QSortColors does not run) only the last two blocks write columnOffset:

columnOffset declared weight slot
at the top of the function 10 (2 + 2 from the first two blocks, 3 + 3 from the last two) -4, above the three locals the original has there (weights 7, 7, 6)
at function level, after the if that holds the first two blocks, or just before the third 10 -4
inside the else that holds the last two blocks 6 -16, the original's; every local at the original's offset

The else alone takes the function from 92.5% to 96.0%. With /GL (together with InitBlendFilterArraysUnk) and two store orders it reaches 100% in #480.

What changes

  • Point 3 says what the def-set holds and gives the counts again: +3 for a def-set local the block also reads, +2 for one it does not read (written here or only in another block), +1 for a local the block only reads and no asm block writes.
  • A new paragraph, "A block scope moves an asm-written local", gives the lever with the numbers above, and says the rule has been traced on this one function so far.
  • slot_probe.py's docstring described the def-set the old way and now says the same as the doc.

Documentation only: the slot_probe.py change is to its docstring, and no game source, header or build file changes, so no function's match percentage can move.

Other PRs. #366 and #396 also change msvc-backend.md (#396 also slot_probe.py), in other places: git merge-tree merges both with this branch exactly as with main.

🤖 Generated with Claude Code

msvc-backend.md's slot-tiebreak section said an __asm block's def-set is the locals that block writes. slot_probe.py
shows more: every asm block puts into its def-set each local that any asm block of the function writes, if the local
is declared in a block that contains it, wherever in that block. So a local written by only some blocks weighs more
than its own references, a declaration moved within the function's block does not change it, and an inner block
holding only the asm that uses it does. Point 3 is corrected (with its +1 / +2 / +3 counts), a paragraph gives the
lever with the probe's numbers (renderUnitAnimationWithBlendingUnk, the one function traced for it so far: 10 at the
top, 6 in the else block, which gives the original's slots), and slot_probe.py's docstring says the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gynt
gynt added this pull request to the merge queue Nov 24, 2026
Merged via the queue into sourcehold:main with commit 74a3ec9 Nov 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants