My assembly versions of R_DrawColumn and R_DrawSpan are more "superoptimized" than what GCC produces at any optimisation level.
The whole functions dispense with need for or use of frame pointer, no register spilling whatsoever. They use only temporary registers, a lot of them, to avoid the need to spill.
They still follow the MIPS C ABI to the letter of the spec.
They make no function calls, use delay slots for useful work, return after 5 instructions when too small to draw and have almost 10 fewer instructions in their inner loop body compared to any GCC generated code. Altogether each function is 20 - 30 instructions shorter than any GCC generated code.
Also, my code schedules every last instruction present to avoid all pipeline stalls from memory loads.
I verified from documentation that there is memory-memory forwarding for potential data hazards like the use of "t0" in the following idiom seen at the end of each texture-mapping inner loop:
Code:
LB t0, 0(t8)
SB t0, 0(t9)
Memory-memory forwarding from 0(t8) to 0(t9) allows this to work without extra stalling required while also allowing the use of the value in "t0" in the instruction following the "SB" instruction without occurring another hazard/penalty/stall, for example:
Code:
# HAZARD
# second use of t0 causes stall
LB t0, 8(t8)
ADDIU t1, t0, 4
# no hazard
# m-m fwd'ing
# no use of t0 causes stall
LB t0, 8(t8)
SB t0, 8(t9)
ADDIU t1, t0, 4