Unrolling pays ramp-up/down every unrolled iteration; software pipelining pays it once per loop
Software-Pipelined Loop, One Op per Iteration
fld f0, 0(x1) # startup: iter 0 load
fadd f4, f0, f2 # iter 0 add
fld f0, -8(x1) # iter 1 load
addi x1, x1, -16
Loop': fsd f4, 16(x1) # store iter i
fadd f4, f0, f2 # add iter i+1
fld f0, 0(x1) # load iter i+2
addi x1, x1, -8
bne x1, x0, Loop'
... # winddown: finish tail
Order matters: fsd reads old f4 before fadd overwrites it; fadd reads old f0 before fld overwrites it
What If There Are No Loops? Trace Scheduling
Branchy code: small basic blocks, little ILP each
Trace scheduling (Fisher & Ellis)
Use profiling or heuristics to pick the most frequent path: a trace
Schedule the whole trace as one big block
Ops moved across side branches need fixup (compensation) code on off-trace paths
Check Your Understanding
1. In Loop', why does fsd come before fadd, and fadd before fld?
fsd must store the previous sum in f4 before fadd overwrites it, and fadd must read the previous load in f0 before fld overwrites it; each belongs to a different iteration.
2. Why does trace scheduling need fixup code on trace exits?
Ops were moved across branches; if execution leaves the trace, fixup code runs skipped ops or undoes speculative effects.
Problems with "Classic" VLIW
Object-code compatibility: latencies and unit counts in the encoding → recompile for every machine
Complex VLIWs approach in-order superscalar hardware complexity with no edge on large irregular apps
Knuth on Itanium: "the wished-for compilers were basically impossible to write"; Itanium discontinued in 2019
Success in embedded DSPs: simple VLIWs, predictable loops, deterministic memory
Check Your Understanding
1. mul (5-cycle) writes f2, add later reads f7; RRB drops by 1 per cycle. At RRB = 10, which register does mul write, and at what RRB does add read it?
mul writes P(2+10) = P12. Five cycles later RRB = 5 and add reads P(7+5) = P12.
2. Why does Load.s set a poison bit instead of faulting?
It was hoisted above a branch; if that path isn't taken the fault would be spurious. Chk.s in the home block raises it only when needed.
← → / space to move · A to reveal answers · F fullscreen