Pipelining 385
Continuing our discussions, we nd that Step 6 is dependent upon Step 4 and Step 3, and unless the
value of R6 has been calculated, this step cannot be executed. However, Step 6 is not dependent upon
Step 5 and these two steps may be executed in any order. The nal step, i.e., Step 7, is dependent upon
both Step 5 as well as Step 6. Therefore, its order cannot be changed and must be executed as the last
one. With this brief introduction to out-of-order execution, let us see how Pentium 4 pipeline is operated.
12.8.3 Register Renaming
Apart from out-of-order execution, register renaming is another technique that is frequently used in
pipelines. Let us consider the following two pseudo-instructions, using the same set of general purpose
registers as we have used earlier.
Step 1 R2 ← R1 + R3
Step 2 R1 ← R4 + R5
If these two instructions are within the pipeline in the same order, then a second instruction cannot
be executed till the completion of the rst instruction. Furthermore, if the second instruction is executed
before the rst instruction, assuming that it was decided to implement out-of-order execution, then it
would generate incorrect result.
In this type of situations, the processor performs a trick. Every processor has some hidden registers
not available for the programmer but available for internal use of the processor. Let us assume H1 is
such a hidden register (of same width as that of R1 ). At an appropriate time the processor changes
instruction 2 of our example to the following instruction:
Step 2 H1 ← R4 + R5
Thus, the result of the operation is stored in the hidden register H1 instead of R1 . Now observe that
there is no problem in processing these two instructions simultaneously. As a matter of fact, there is no
harm to execute the second instruction before the rst instruction (out-of-order execution). The only
thing we should keep in our mind is that at an appropriate time, the processor replaces the value of R1
by the value contained in the hidden register H1 .
12.8.4 Speculative Execution
Another technique to help in expediting pipeline execution is the speculative execution, which is a spe-
cial type of out-of-order execution. Speculative execution may be considered for load or other similar
operations but never for branch or loop modules of any program which guides the ow of control of the
program. However, as any eventual cache-miss of the speculative load type instruction execution would
rather degrade than enhancing the pipeline performance, therefore, it should be carefully implemented
by the compiler or the operating system.
12.8.5 Stages of P4 Pipeline
As indicated in Table 12.1 , Pentium 4 has a 20-stage pipeline, which is schematically depicted in Figure
12.12 . We should keep two points in our mind during the discussions on these pipeline activities of
Pentium 4. These two points are
R Instructions of Pentium 4 are CISC-like in nature and they are broken down and translated to
uniform RISC-like micro-operations before the execution.
R Pentium 4 pipeline permits out-of-order execution that is the order of actual execution of instructions
may not follow the same sequence as they appear in the original program, which is being executed.
M12_GHOS1557_01_SE_C12.indd 385M12_GHOS1557_01_SE_C12.indd 385 4/29/11 5:24 PM4/29/11 5:24 PM