mirror of
https://github.com/Druthulu/BFM-decomp
synced 2026-09-27 14:02:04 -04:00
16c4fc75e1
Byte-proven on ov_SC04_016/func_8017DF8C (184 ins, 32 -> 0 in seven compiles). 1. Writing the stride as `off = j * 0x50` (a giv of biv j) rather than a second biv fixes 14 preheader rows and 8 latch rows at once: loop.c chains givs LIFO (loop.c:4421), so with `j = 0` spelled first the `move $s0,$zero` emits last and the arg-3 giv lands in its natural record slot. When the PREHEADER ORDER is wrong, check which variables are bivs and which are givs before touching anything else. 2. To emit la + addu + lh 0(reg) instead of a folded %hi/%lo(sym+K), hoist the table pointer to a function-scope local set ONCE outside both loops. No LOG_LINK crosses basic blocks so combine cannot fold it, and with every $s taken reload rematerialises it from reg_equiv_constant at the use and deletes the init - so the hoist is free. Spell the sum `idx + (s32)tbl`; the reverse costs one operand swap. Measured inert here: §328's volatile cast on a reg+sym address.