Course: Computer Architectures

Lecture: Lecture 07 - Instruction-Level Parallelism

Definition

Instruction-level parallelism (ILP) is the opportunity to overlap independent instructions while preserving program behavior. A pipeline exploits some ILP even when it starts only one instruction per cycle. ILP is not the same as running several software threads.

Static and dynamic approaches

ApproachWho finds/exposes parallel work?Example mechanism
StaticCompilerReorder independent instructions, unroll loops, rename temporary registers
DynamicHardwareSelect ready work according to runtime operands and resources

The approaches can coexist. An ISA such as RISC-V does not alone determine whether a processor uses in-order or out-of-order scheduling. See Instruction Dependencies for the constraints both approaches must respect.

Basic blocks

A basic block is a straight-line instruction sequence with entry only at its start and exit only at its end. There are no branch targets or outgoing branches in its interior.

Slide 7’s while (save[i] == k) i += 1; example contains two blocks: address calculation/load/conditional branch, then increment/unconditional jump. A whole loop is not necessarily one basic block.

Within a block, the compiler can reschedule instructions subject to data, name, memory, and correctness constraints. Small blocks limit the pool of independent work; Loop Unrolling and SIMD extends the opportunity across iterations.

Worked scheduling example

Source and assumptions (slides 8-12)

The stated source is a = b + c; d = e - f;. All variables are in memory. The lecture assumes one cycle of load-use separation, a single-issue five-stage pipeline, and sufficient forwarding for the shown schedules. The address registers x10...x15 are already set.

Source correction: The printed assembly uses addition for the second expression. It is reproduced below; replace the second add with sub to implement e - f. That replacement has the same latency in this teaching model.

The reordering also assumes that moving loads ahead of the first store is safe: the relevant locations do not alias in a way that changes values, and exception ordering is acceptable. Arbitrary pointer-based code needs that proof.

Original slide code

lw  x1, 0(x10)
lw  x2, 0(x11)
add x5, x1, x2
sw  x5, 0(x14)
lw  x3, 0(x12)
lw  x4, 0(x13)
add x6, x3, x4
sw  x6, 0(x15)

The first add immediately follows the load of x2; the second add immediately follows the load of x4. Each needs one load-use stall.

For the first dependency:

InstructionC2C3C4C5C6
lw x2IFIDEXMEMWB
add x5IFIDStallEX

The load produces its data at the end of MEM in C5. The add cannot use it in EX in that same cycle, so EX moves to C6. Forwarding delivers the value once ready; it cannot make it available sooner.

Rescheduled slide code

lw  x1, 0(x10)
lw  x2, 0(x11)
lw  x3, 0(x12)
add x5, x1, x2
lw  x4, 0(x13)
sw  x5, 0(x14)
add x6, x3, x4
sw  x6, 0(x15)

Step by step:

  1. Move the independent lw x3 into the gap between lw x2 and its add.
  2. Start lw x4 after the first add.
  3. Place the first store between lw x4 and the second add. This is useful work while the load result becomes available.
  4. Each add still consumes its own loads, and each store still consumes its own add. Only safe independent work changes position.

Cycle accounting

Under the lecture’s nominal five-stage completion accounting, eight instructions without stalls take:

ScheduleInstructionsLoad-use stallsTotal cycles
Original8214
Rescheduled8012

Speedup and percentage time reduction use different denominators. Stores perform their memory effect in MEM in this model; the slide’s total counts passage through the final nominal stage. These are lecture timings, not measurements from ASE Studio.

Limits and common mistakes

  • Renaming cannot eliminate true data flow.
  • Independent instructions can still compete for a functional unit or memory port.
  • Changing the instruction order requires checking aliasing and exception behavior, not just matching register names.
  • Removing stalls does not reduce the instruction count in this example.
  • A faster schedule for this model need not be faster on every processor.

Pipelining, Latency and Initiation Interval, Instruction Dependencies, Register Renaming, Loop Unrolling and SIMD, Control Dependencies and Speculation.

E. Sanchez, Instruction Level Parallelism, ASE 2026/27, slides 2-13. PDF: Instruction Level Parallelism.pdf. Cycle equations and legality qualifications are explanatory additions to the slide example.