# develop-16 9312 December 1993 — source transcripts, page 2

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-develop-16-9312-december-1993-a3fb4a/2)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### PDF page 12

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-16-9312-december-1993-a3fb4a/2#scan-47aaaa060ffab2834c3d74c471e172ee5db92c648e94567cf190cfa31431eec9)

Transcribed text:

the pipeline is kept full like this, the number of cycles per instruction drops to just
one. This is the goal of most RISC architectures.
One cycle per instruction is the ideal case for this example, but in reality, stalls and
bubbles occur, even in the best architectures. This is where the compiler comes into
play. The compiler has detailed knowledge of how the program should work. It need
not perform operations in the order specified in the source code; it need only
guarantee that the right result is obtained. If you build into the compiler some
knowledge of how to make best use of the CPU, the compiler can make a huge
difference in program performance.
Consider the following two C instructions:
b   =   *a   +   5;
d   =   *c   +   10;
The variables   a ,   b ,   c , and   d   are all long or pointer-to-long variables. The compiler
might generate the following assembly instructions on the PowerPC microprocessor:
lwz   r5,0(r3)   ;   Load   value   pointed   to   by   r3   into   r5
addi   r5,r5,0x0005   ;   Add   5   to   value   in   r5
lwz   r6,0(r4)   ;   Load   value   pointed   to   by   r4   into   r6
addi   r6,r6,0x000a   ;   Add   10   to   value   in   r6
The   lwz   instruction (Load Word and Zero) loads a register from a source value. On a
PowerPC processor, words are 32-bit values; 16-bit values are half words. The   addi
instruction (Add Immediate) adds the immediate value and stores the result.
Figure 5 shows what happens when these instructions execute. Both   addi   instructions
stall in the decode stage because they can’t enter the execute stage until the register is
available from the   lwz   instruction.
The compiler can prevent the stalls. Instead of following the flow of the original
source code, you can rearrange the instructions as follows:
lwz   r5,0(r3)   ;   Load   value   pointed   to   by   r3   into   r5
lwz   r6,0(r4)   ;   Load   value   pointed   to   by   r4   into   r6
addi   r5,r5,0x0005   ;   Add   5   to   value   in   r5
addi   r6,r6,0x000a   ;   Add   10   to   value   in   r6
Now look at what happens to the instruction pipeline (Figure 6): there are no delays.
By moving the add instructions to later in the instruction stream, you allow the load
instructions they depend on to complete, so the add instructions can execute
immediately.
d e v e l o p   Issue 16
10

Languages: English

[Original PDF page 12](https://www.vintageapple.net/files/27615486e815eec6d5aa31b5c10fd9a97a3e645cfa19601a7a9351cb0b00bff9/develop-16_9312_December_1993.pdf#page=12)

[Previous transcribed scans](https://www.vintageapple.net/transcripts/media/va-develop-16-9312-december-1993-a3fb4a/1.md)
