ProgressHandler¶
ProgressHandler (ob_003bc914, src/hitman3/gui/mcprogressps2.cpp, 1,168 bytes) is the one game function still built from its assembly fallback. This note records the state on 18 November 2026.
The draft emits all 292 instructions in the original order. It keeps the advance speed in $f5 and the bar width in $f4; the original has them the other way round. Every other register, immediate and relocation matches.
What the debug record settled¶
research-tools/debug_blocks.py compares the original's $LBB block numbers and the registers of the variables in each block with a -g build of the draft. It found three differences that earlier rounds missed. All three are now in the source:
- The last three value and register pairs of the second packet are
AddRegcalls. Their stores sit four scope levels deep in the original, and the statements then fit lines 98 to 124 with one line to spare. uNloopkeeps the value 5. It is declared after the first packet, the first GIF tag is passed toAdd64as an expression, and the laterAdd64(GS_CLAMP_CLAMP_UV)reuses its register.EndPackethas the localslByteSizeandlqSize, andEndDirectPackethaslByteSize.
Three more facts are left out of the source because they do not change the code:
- The function is
staticand its parameter is nameda. syncandeiare one statement on line 140 with no inline scope, which fits Sony'sExitHandler()macro. The draft usesZSyncMemory()andZEnableInterrupts().- The unit compiled
static int GetNeededBones(uint8 *pNeededBones, const ZBoneConstraint *pBoneConstraint)fromengine/drawing/zprimcontrolbase.hbeforeProgressHandler(blocks 2 to 9, 0x60 bytes, dropped at link). The tree has no such function. A function compiled ahead ofProgressHandlerdid not change its code.
Apart from those three, block numbers, per-block variable registers and the source line of every instruction equal the original's.
The remaining difference¶
Local register allocation gives $f4 to whichever of the two values has the higher priority (references times frequency over live span). The width has 3,200,000. The advance speed has 3,076,923 with a span of 26, and a span of 24 would give it 3,333,333.
The span is set by the first scheduling pass. In the block that starts after the if (g_bType) arms, cycle 9 has one slot left for an ALU instruction and two candidates with priority 103 and register weight 1:
| insn | dependents | luid |
|---|---|---|
pGifTag = lo_sum(high, g_GifTagRegsAD) |
4: block end, sync, the call, the second ld |
85 |
high(g_startx) |
3: block end, sync, the lw |
44 |
The first wins on dependents and lands between the advance-speed load and its multiply. The original must have picked something else there.
Forced orders that match¶
research-tools/probe.py runs the compiler with a preload library that can force one insn above another in the ready list (PH_ABOVE=a:b, insn UIDs). research-tools/flip.py tries such pairs across the block. The function scores 0 when one of these takes the slot instead of the lo_sum:
high(g_startx), picked anywhere from cycle 7 to cycle 9;high(g_readme);- the constant of
Add32(VIF_FLUSH)or ofAdd32(VIFCODE_DIRECT).
All four are single-use values that local-alloc later moves next to their use, so they do not count in the span. The lw of g_startx has to stay after the loads of g_starty and g_height; moving it earlier gives 135 or more.
Three changes to the pass's inputs also give 0: marking the pseudo that holds high(g_GifTagRegsAD) as crossing a call, one more reference frequency (1000) on the advance-speed pseudo, or one fewer on the width product.
No source form that produces any of these has been found.
The scheduler in this compiler¶
Measured with the preload library. sched-deps.c in build/gccsrc (3.2.3) differs in places.
- Every dependence costs the latency of the earlier insn whatever its kind: ALU 1, load or store 2, FP arithmetic 4. Links to the final
useand to anasminsn cost nothing. The first call has priority 98, an ALU insn before it 99, a store 100. - Anti and output dependences between memory references check alias sets.
intloads are tied to lateruint32packet stores,uint64loads to earlieruint64stores, and stores to pointer members to each other. - An
asminsn is a barrier that every earlier insn precedes. The link from the last setter of a register is an output dependence. - A use of a pseudo that crosses no call makes the next call depend on the insn. A set does not.
- Forward dependence lists are never returned to the free list, so the cost flags cached on them are never stale.
Ruled out¶
- About 130 compiler flags and the
ee-gcc3.2-030926compiler. lRight *= 16: the call then waits for the shift, the float registers come out right, and the integer schedule of the whole block changes.- Other load types in
BeginGifPacket: the twoldhave to share an alias set with theAdd64stores. - the historical mutation script (available with
git show ee3346987^:tools/mutate.py) (650 candidates),ZASSERTandZTRACEplacements, clamp forms on lines 76 to 81,uNloopdeclared before the first packet. - The pending-memory-list flush: the block has 28 references before the first call and the limit is 32.
Research tools¶
All in research-tools/, specific to this function.
debug_blocks.py <copy.cpp>:$LBBnumbers and per-block variable registers, original against a-gbuild.line_tags.py <copy.cpp>andline_labels.py <copy.cpp>: the source line of every instruction, and the full$LMlabel sequence including labels with no code.shim/build.sh: builds the preload library intobuild/ph/shim.probe.py <copy.cpp> [--sched]: priority and span of the two float quantities, the score, and the tie. Environment:PH_ABOVE=a:b[,c:d]forces an order,PH_DEPS=1lists dependents with their cost flags,PH_PRIO=lo:hiprints priority, weight and dependents for a UID range,PH_CROSS=regnomarks a pseudo as crossing a call,PH_FREQ=regnowithPH_FREQ_DELTA=nchanges a reference frequency.flip.py <copy.cpp> <uid,uid,...>: forces each later insn of the list above each of the twelve before it and reports the pairs that lower the score.
<copy.cpp> is a path inside the repository, for example src/hitman3/gui/mcprogressps2.cpp.